From 5453c68399f25ee49c7300d54c2b83997b5b964a Mon Sep 17 00:00:00 2001 From: sholdee <102821812+sholdee@users.noreply.github.com> Date: Mon, 8 Aug 2022 18:59:43 -0500 Subject: [PATCH] [ci] docker improvements (#1101) --- Jenkinsfile | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5f976bb4e..80df7b0cc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -67,8 +67,8 @@ pipeline { move "_packages\\*.zip" "soh.zip" """ - archiveArtifacts artifacts: 'soh.zip', followSymlinks: false, onlyIfSuccessful: true } + archiveArtifacts artifacts: 'soh.zip', followSymlinks: false, onlyIfSuccessful: true } post { always { @@ -91,6 +91,7 @@ pipeline { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { unstash 'assets' sh ''' + if docker ps -aq --filter "name=sohcont" | grep -q .; then docker rm -f sohcont; fi docker build . -t soh docker run --name sohcont -dit --rm -v $(pwd):/soh soh /bin/bash docker exec sohcont scripts/linux/appimage/build.sh @@ -102,11 +103,12 @@ pipeline { ''' } - sh 'sudo docker container stop sohcont' archiveArtifacts artifacts: 'soh-linux.7z', followSymlinks: false, onlyIfSuccessful: true } post { always { + sh 'sudo docker container stop sohcont' + sh 'docker images --quiet --filter=dangling=true | xargs --no-run-if-empty docker rmi' // Clean dangling docker images step([$class: 'WsCleanup']) // Clean workspace } } @@ -159,9 +161,10 @@ pipeline { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { unstash 'assets' sh ''' + if docker ps -aq --filter "name=sohswitchcont" | grep -q .; then docker rm -f sohswitchcont; fi docker build . -t sohswitch - docker run --name sohcont -dit --rm -v $(pwd):/soh sohswitch /bin/bash - docker exec sohcont scripts/switch/build.sh + docker run --name sohswitchcont -dit --rm -v $(pwd):/soh sohswitch /bin/bash + docker exec sohswitchcont scripts/switch/build.sh mv build-switch/soh/*.nro soh.nro mv README.md readme.txt @@ -170,11 +173,12 @@ pipeline { ''' } - sh 'sudo docker container stop sohcont' archiveArtifacts artifacts: 'soh-switch.7z', followSymlinks: false, onlyIfSuccessful: true } post { always { + sh 'sudo docker container stop sohswitchcont' + sh 'docker images --quiet --filter=dangling=true | xargs --no-run-if-empty docker rmi' // Clean dangling docker images step([$class: 'WsCleanup']) // Clean workspace } }