[ci] docker improvements (#1101)

This commit is contained in:
sholdee 2022-08-08 18:59:43 -05:00 committed by GitHub
parent c803ff65ce
commit 5453c68399
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

14
Jenkinsfile vendored
View File

@ -67,8 +67,8 @@ pipeline {
move "_packages\\*.zip" "soh.zip" move "_packages\\*.zip" "soh.zip"
""" """
archiveArtifacts artifacts: 'soh.zip', followSymlinks: false, onlyIfSuccessful: true
} }
archiveArtifacts artifacts: 'soh.zip', followSymlinks: false, onlyIfSuccessful: true
} }
post { post {
always { always {
@ -91,6 +91,7 @@ pipeline {
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
unstash 'assets' unstash 'assets'
sh ''' sh '''
if docker ps -aq --filter "name=sohcont" | grep -q .; then docker rm -f sohcont; fi
docker build . -t soh docker build . -t soh
docker run --name sohcont -dit --rm -v $(pwd):/soh soh /bin/bash docker run --name sohcont -dit --rm -v $(pwd):/soh soh /bin/bash
docker exec sohcont scripts/linux/appimage/build.sh 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 archiveArtifacts artifacts: 'soh-linux.7z', followSymlinks: false, onlyIfSuccessful: true
} }
post { post {
always { 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 step([$class: 'WsCleanup']) // Clean workspace
} }
} }
@ -159,9 +161,10 @@ pipeline {
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
unstash 'assets' unstash 'assets'
sh ''' sh '''
if docker ps -aq --filter "name=sohswitchcont" | grep -q .; then docker rm -f sohswitchcont; fi
docker build . -t sohswitch docker build . -t sohswitch
docker run --name sohcont -dit --rm -v $(pwd):/soh sohswitch /bin/bash docker run --name sohswitchcont -dit --rm -v $(pwd):/soh sohswitch /bin/bash
docker exec sohcont scripts/switch/build.sh docker exec sohswitchcont scripts/switch/build.sh
mv build-switch/soh/*.nro soh.nro mv build-switch/soh/*.nro soh.nro
mv README.md readme.txt 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 archiveArtifacts artifacts: 'soh-switch.7z', followSymlinks: false, onlyIfSuccessful: true
} }
post { post {
always { 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 step([$class: 'WsCleanup']) // Clean workspace
} }
} }