22// SPDX-License-Identifier: Apache-2.0
33
44pipeline {
5- agent { label 'docker ' }
5+ agent { label 'podman ' }
66 stages{
77 stage('DE tests') {
88 parallel {
99 stage('flake8') {
1010 agent {
1111 node {
12- label 'docker '
12+ label 'podman '
1313 customWorkspace "${WORKSPACE}/${STAGE_NAME}"
1414 }
1515 }
@@ -19,7 +19,7 @@ pipeline {
1919 steps {
2020 script {
2121 // DOCKER_IMAGE is defined through Jenkins project
22- flake8StageDockerImage="${DOCKER_IMAGE}_${BUILD_NUMBER}_${STAGE_NAME}"
22+ flake8StageDockerImage="localhost/ ${DOCKER_IMAGE}_${BUILD_NUMBER}_${STAGE_NAME}"
2323 // Set custom Build Name
2424 if (params.GITHUB_PR_NUMBER) {
2525 if (params.GITHUB_PR_STATE == 'CLOSED') {
@@ -47,34 +47,34 @@ pipeline {
4747 fi
4848 cd ..
4949 '''
50- echo "prepare docker image ${flake8StageDockerImage}"
51- sh "docker build --pull --tag ${flake8StageDockerImage} --build-arg BASEIMAGE=hepcloud/decision-engine-ci-el9:${BRANCH} --build-arg UID=\$(id -u) --build-arg GID=\$(id -g) -f decisionengine/package/ci/EL9/Dockerfile decisionengine/package/ci/EL9/"
50+ echo "prepare podman image ${flake8StageDockerImage}"
51+ sh "podman build --pull --tag ${flake8StageDockerImage} --build-arg BASEIMAGE=docker.io/ hepcloud/decision-engine-ci-el9:${BRANCH} --build-arg UID=\$(id -u) --build-arg GID=\$(id -g) -f decisionengine/package/ci/EL9/Dockerfile decisionengine/package/ci/EL9/"
5252 echo "Run ${STAGE_NAME} tests"
53- sh "docker run --rm --env PYTEST_TIMEOUT=${PYTEST_TIMEOUT} -v ${WORKSPACE}/decisionengine:${WORKSPACE}/decisionengine -w ${WORKSPACE}/decisionengine ${flake8StageDockerImage} \"-m flake8\" \"flake8.log\""
53+ sh "podman run --userns keep-id:uid=\$(id -u),gid=\$(id -g) --rm --env PYTEST_TIMEOUT=${PYTEST_TIMEOUT} -v ${WORKSPACE}/decisionengine:${WORKSPACE}/decisionengine -w ${WORKSPACE}/decisionengine ${flake8StageDockerImage} \"-m flake8\" \"flake8.log\""
5454 }
5555 post {
5656 always {
5757 archiveArtifacts artifacts: "decisionengine/flake8.log"
58- // check if the docker container used for this test suite is still active, if so this is due to an aborted test suite
58+ // check if the podman container used for this test suite is still active, if so this is due to an aborted test suite
5959 // eventually kill the python process that spawn the test to cleanup CI processes left behind
6060 sh '''
61- DOCKERID =$(docker ps | grep ${DOCKER_IMAGE}_${BUILD_NUMBER}_${STAGE_NAME} | awk '{print $1}')
62- if [[ -n ${DOCKERID } ]]; then
63- docker exec ${DOCKERID } ps -xww && \
64- KPID=$(docker exec ${DOCKERID } ps -xww | grep python3 | head -1 | awk '{print $1}') && \
65- docker exec ${DOCKERID } kill -9 ${KPID} || true
66- docker exec ${DOCKERID } ps -xww || true
61+ PODMANID =$(podman ps | grep ${DOCKER_IMAGE}_${BUILD_NUMBER}_${STAGE_NAME} | awk '{print $1}')
62+ if [[ -n ${PODMANID } ]]; then
63+ podman exec ${PODMANID } ps -xww && \
64+ KPID=$(podman exec ${PODMANID } ps -xww | grep python3 | head -1 | awk '{print $1}') && \
65+ podman exec ${PODMANID } kill -9 ${KPID} || true
66+ podman exec ${PODMANID } ps -xww || true
6767 fi
6868 '''
69- echo "cleanup docker image ${flake8StageDockerImage}"
70- sh "docker rmi ${flake8StageDockerImage}"
69+ echo "cleanup podman image ${flake8StageDockerImage}"
70+ sh "podman rmi ${flake8StageDockerImage}"
7171 }
7272 }
7373 }
7474 stage('pylint') {
7575 agent {
7676 node {
77- label 'docker '
77+ label 'podman '
7878 customWorkspace "${WORKSPACE}/${STAGE_NAME}"
7979 }
8080 }
@@ -84,7 +84,7 @@ pipeline {
8484 steps {
8585 script {
8686 // DOCKER_IMAGE is defined through Jenkins project
87- pylintStageDockerImage="${DOCKER_IMAGE}_${BUILD_NUMBER}_${STAGE_NAME}"
87+ pylintStageDockerImage="localhost/ ${DOCKER_IMAGE}_${BUILD_NUMBER}_${STAGE_NAME}"
8888 }
8989 echo "cleanup workspace"
9090 sh 'for f in $(ls -A); do rm -rf ${f}; done'
@@ -102,34 +102,34 @@ pipeline {
102102 fi
103103 cd ..
104104 '''
105- echo "prepare docker image ${pylintStageDockerImage}"
106- sh "docker build --pull --tag ${pylintStageDockerImage} --build-arg BASEIMAGE=hepcloud/decision-engine-ci-el9:${BRANCH} --build-arg UID=\$(id -u) --build-arg GID=\$(id -g) -f decisionengine/package/ci/EL9/Dockerfile decisionengine/package/ci/EL9/"
105+ echo "prepare podman image ${pylintStageDockerImage}"
106+ sh "podman build --pull --tag ${pylintStageDockerImage} --build-arg BASEIMAGE=docker.io/ hepcloud/decision-engine-ci-el9:${BRANCH} --build-arg UID=\$(id -u) --build-arg GID=\$(id -g) -f decisionengine/package/ci/EL9/Dockerfile decisionengine/package/ci/EL9/"
107107 echo "Run ${STAGE_NAME} tests"
108- sh "docker run --rm --env PYTEST_TIMEOUT=${PYTEST_TIMEOUT} -v ${WORKSPACE}/decisionengine:${WORKSPACE}/decisionengine -w ${WORKSPACE}/decisionengine ${pylintStageDockerImage} \"-m pylint src/decisionengine/ src/tests/\" \"pylint.log\""
108+ sh "podman run --userns keep-id:uid=\$(id -u),gid=\$(id -g) --rm --env PYTEST_TIMEOUT=${PYTEST_TIMEOUT} -v ${WORKSPACE}/decisionengine:${WORKSPACE}/decisionengine -w ${WORKSPACE}/decisionengine ${pylintStageDockerImage} \"-m pylint src/decisionengine/ src/tests/\" \"pylint.log\""
109109 }
110110 post {
111111 always {
112112 archiveArtifacts artifacts: "decisionengine/pylint.log"
113- // check if the docker container used for this test suite is still active, if so this is due to an aborted test suite
113+ // check if the podman container used for this test suite is still active, if so this is due to an aborted test suite
114114 // eventually kill the python process that spawn the test to cleanup CI processes left behind
115115 sh '''
116- DOCKERID =$(docker ps | grep ${DOCKER_IMAGE}_${BUILD_NUMBER}_${STAGE_NAME} | awk '{print $1}')
117- if [[ -n ${DOCKERID } ]]; then
118- docker exec ${DOCKERID } ps -xww && \
119- KPID=$(docker exec ${DOCKERID } ps -xww | grep python3 | head -1 | awk '{print $1}') && \
120- docker exec ${DOCKERID } kill -9 ${KPID} || true
121- docker exec ${DOCKERID } ps -xww || true
116+ PODMANID =$(podman ps | grep ${DOCKER_IMAGE}_${BUILD_NUMBER}_${STAGE_NAME} | awk '{print $1}')
117+ if [[ -n ${PODMANID } ]]; then
118+ podman exec ${PODMANID } ps -xww && \
119+ KPID=$(podman exec ${PODMANID } ps -xww | grep python3 | head -1 | awk '{print $1}') && \
120+ podman exec ${PODMANID } kill -9 ${KPID} || true
121+ podman exec ${PODMANID } ps -xww || true
122122 fi
123123 '''
124- echo "cleanup docker image ${pylintStageDockerImage}"
125- sh "docker rmi ${pylintStageDockerImage}"
124+ echo "cleanup podman image ${pylintStageDockerImage}"
125+ sh "podman rmi ${pylintStageDockerImage}"
126126 }
127127 }
128128 }
129129 stage('unit_tests') {
130130 agent {
131131 node {
132- label 'docker '
132+ label 'podman '
133133 customWorkspace "${WORKSPACE}/${STAGE_NAME}"
134134 }
135135 }
@@ -139,7 +139,7 @@ pipeline {
139139 steps {
140140 script {
141141 // DOCKER_IMAGE is defined through Jenkins project
142- unit_testsStageDockerImage="${DOCKER_IMAGE}_${BUILD_NUMBER}_${STAGE_NAME}"
142+ unit_testsStageDockerImage="localhost/ ${DOCKER_IMAGE}_${BUILD_NUMBER}_${STAGE_NAME}"
143143 }
144144 echo "cleanup workspace"
145145 sh 'for f in $(ls -A); do rm -rf ${f}; done'
@@ -157,34 +157,34 @@ pipeline {
157157 fi
158158 cd ..
159159 '''
160- echo "prepare docker image ${unit_testsStageDockerImage}"
161- sh "docker build --pull --tag ${unit_testsStageDockerImage} --build-arg BASEIMAGE=hepcloud/decision-engine-ci-el9:${BRANCH} --build-arg UID=\$(id -u) --build-arg GID=\$(id -g) -f decisionengine/package/ci/EL9/Dockerfile decisionengine/package/ci/EL9/"
160+ echo "prepare podman image ${unit_testsStageDockerImage}"
161+ sh "podman build --pull --tag ${unit_testsStageDockerImage} --build-arg BASEIMAGE=docker.io/ hepcloud/decision-engine-ci-el9:${BRANCH} --build-arg UID=\$(id -u) --build-arg GID=\$(id -g) -f decisionengine/package/ci/EL9/Dockerfile decisionengine/package/ci/EL9/"
162162 echo "Run ${STAGE_NAME} tests"
163- sh "docker run --rm --env PYTEST_TIMEOUT=${PYTEST_TIMEOUT} -v ${WORKSPACE}/decisionengine:${WORKSPACE}/decisionengine -w ${WORKSPACE}/decisionengine ${unit_testsStageDockerImage} \"-m pytest --cov-report term --cov=decisionengine --no-cov-on-fail\" \"pytest.log\""
163+ sh "podman run --userns keep-id:uid=\$(id -u),gid=\$(id -g) --rm --env PYTEST_TIMEOUT=${PYTEST_TIMEOUT} -v ${WORKSPACE}/decisionengine:${WORKSPACE}/decisionengine -w ${WORKSPACE}/decisionengine ${unit_testsStageDockerImage} \"-m pytest --cov-report term --cov=decisionengine --no-cov-on-fail\" \"pytest.log\""
164164 }
165165 post {
166166 always {
167167 archiveArtifacts artifacts: "decisionengine/pytest.log"
168- // check if the docker container used for this test suite is still active, if so this is due to an aborted test suite
168+ // check if the podman container used for this test suite is still active, if so this is due to an aborted test suite
169169 // eventually kill the python process that spawn the test to cleanup CI processes left behind
170170 sh '''
171- DOCKERID =$(docker ps | grep ${DOCKER_IMAGE}_${BUILD_NUMBER}_${STAGE_NAME} | awk '{print $1}')
172- if [[ -n ${DOCKERID } ]]; then
173- docker exec ${DOCKERID } ps -xww && \
174- KPID=$(docker exec ${DOCKERID } ps -xww | grep python3 | head -1 | awk '{print $1}') && \
175- docker exec ${DOCKERID } kill -9 ${KPID} || true
176- docker exec ${DOCKERID } ps -xww || true
171+ PODMANID =$(podman ps | grep ${DOCKER_IMAGE}_${BUILD_NUMBER}_${STAGE_NAME} | awk '{print $1}')
172+ if [[ -n ${PODMANID } ]]; then
173+ podman exec ${PODMANID } ps -xww && \
174+ KPID=$(podman exec ${PODMANID } ps -xww | grep python3 | head -1 | awk '{print $1}') && \
175+ podman exec ${PODMANID } kill -9 ${KPID} || true
176+ podman exec ${PODMANID } ps -xww || true
177177 fi
178178 '''
179- echo "cleanup docker image ${unit_testsStageDockerImage}"
180- sh "docker rmi ${unit_testsStageDockerImage}"
179+ echo "cleanup podman image ${unit_testsStageDockerImage}"
180+ sh "podman rmi ${unit_testsStageDockerImage}"
181181 }
182182 }
183183 }
184184 stage('rpmbuild') {
185185 agent {
186186 node {
187- label 'docker '
187+ label 'podman '
188188 customWorkspace "${WORKSPACE}/${STAGE_NAME}"
189189 }
190190 }
@@ -194,7 +194,7 @@ pipeline {
194194 steps {
195195 script {
196196 // DOCKER_IMAGE is defined through Jenkins project
197- rpmbuildStageDockerImage="${DOCKER_IMAGE}_${BUILD_NUMBER}_${STAGE_NAME}"
197+ rpmbuildStageDockerImage="localhost/ ${DOCKER_IMAGE}_${BUILD_NUMBER}_${STAGE_NAME}"
198198 }
199199 echo "cleanup workspace"
200200 sh 'for f in $(ls -A); do rm -rf ${f}; done'
@@ -212,27 +212,27 @@ pipeline {
212212 fi
213213 cd ..
214214 '''
215- echo "prepare docker image ${rpmbuildStageDockerImage}"
216- sh "docker build --pull --tag ${rpmbuildStageDockerImage} --build-arg BASEIMAGE=hepcloud/decision-engine-ci-el9:${BRANCH} --build-arg UID=\$(id -u) --build-arg GID=\$(id -g) -f decisionengine/package/ci/EL9/Dockerfile decisionengine/package/ci/EL9/"
215+ echo "prepare podman image ${rpmbuildStageDockerImage}"
216+ sh "podman build --pull --tag ${rpmbuildStageDockerImage} --build-arg BASEIMAGE=docker.io/ hepcloud/decision-engine-ci-el9:${BRANCH} --build-arg UID=\$(id -u) --build-arg GID=\$(id -g) -f decisionengine/package/ci/EL9/Dockerfile decisionengine/package/ci/EL9/"
217217 echo "Run ${STAGE_NAME} tests"
218- sh "docker run --rm --env PYTEST_TIMEOUT=${PYTEST_TIMEOUT} -v ${WORKSPACE}/decisionengine:${WORKSPACE}/decisionengine -w ${WORKSPACE}/decisionengine ${rpmbuildStageDockerImage} \"setup.py bdist_rpm\" \"rpmbuild.log\""
218+ sh "podman run --userns keep-id:uid=\$(id -u),gid=\$(id -g) --rm --env PYTEST_TIMEOUT=${PYTEST_TIMEOUT} -v ${WORKSPACE}/decisionengine:${WORKSPACE}/decisionengine -w ${WORKSPACE}/decisionengine ${rpmbuildStageDockerImage} \"setup.py bdist_rpm\" \"rpmbuild.log\""
219219 }
220220 post {
221221 always {
222222 archiveArtifacts artifacts: "decisionengine/rpmbuild.log,decisionengine/dist/*.rpm"
223- // check if the docker container used for this test suite is still active, if so this is due to an aborted test suite
223+ // check if the podman container used for this test suite is still active, if so this is due to an aborted test suite
224224 // eventually kill the python process that spawn the test to cleanup CI processes left behind
225225 sh '''
226- DOCKERID =$(docker ps | grep ${DOCKER_IMAGE}_${BUILD_NUMBER}_${STAGE_NAME} | awk '{print $1}')
227- if [[ -n ${DOCKERID } ]]; then
228- docker exec ${DOCKERID } ps -xww && \
229- KPID=$(docker exec ${DOCKERID } ps -xww | grep python3 | head -1 | awk '{print $1}') && \
230- docker exec ${DOCKERID } kill -9 ${KPID} || true
231- docker exec ${DOCKERID } ps -xww || true
226+ PODMANID =$(podman ps | grep ${DOCKER_IMAGE}_${BUILD_NUMBER}_${STAGE_NAME} | awk '{print $1}')
227+ if [[ -n ${PODMANID } ]]; then
228+ podman exec ${PODMANID } ps -xww && \
229+ KPID=$(podman exec ${PODMANID } ps -xww | grep python3 | head -1 | awk '{print $1}') && \
230+ podman exec ${PODMANID } kill -9 ${KPID} || true
231+ podman exec ${PODMANID } ps -xww || true
232232 fi
233233 '''
234- echo "cleanup docker image ${rpmbuildStageDockerImage}"
235- sh "docker rmi ${rpmbuildStageDockerImage}"
234+ echo "cleanup podman image ${rpmbuildStageDockerImage}"
235+ sh "podman rmi ${rpmbuildStageDockerImage}"
236236 }
237237 }
238238 }
0 commit comments