pipeline { agent { label 'pi501.in.thelinuxpro.net' } stages { stage("verify tooling") { steps { sh ''' docker version docker info docker compose version ''' } } stage("Build Containers and push to registry") { steps { script { def status = sh(returnStatus: true, script: 'docker images | grep nagios | grep $(grep image docker-compose.yml | awk -F\':\' \'{ print $4 }\')') if (status_p != 0) { sh 'docker compose build --push' } else { echo "Primary Image version already exists, no need to rebuild." } } } } stage('Create contexts') { steps { sh 'docker context ls | grep pi503 || docker context create pi503 --docker "host=ssh://pi503.in.thelinuxpro.net"' } } stage('Stop container') { steps { script { def status_s = sh(returnStatus: true, script: 'grep $(docker --context pi503 compose ps | tail -n1 | awk \'{ print $2 }\') docker-compose.yml') if (status_s != 0) { sh 'docker --context pi503 compose down' sh 'sleep 5' } else { echo 'skip' } } } } stage('Start container') { steps { script { def status_s = sh(returnStatus: true, script: 'grep $(docker --context pi503 compose ps | tail -n1 | awk \'{ print $2 }\') docker-compose.yml') if (status_s != 0) { sh 'docker --context pi503 compose up -d' sh 'docker --context pi503 compose ps' } else { echo 'skip' } } } } # stage('Integration Tests') { # steps { # sh 'mkdir -p test/results/integration' # sh 'bats -F junit test/integration/dns/thelinux.pro/*.bat test/integration/dns/thelinux.pro/**/*.bat > test/results/integration/TEST-Integration-dns-thelinux_pro.xml' # sh 'bats -F junit test/integration/dns/kameronkenny.com/*.bat test/integration/dns/kameronkenny.com/**/*.bat > test/results/integration/TEST-Integration-dns-kameronkenny_com.xml' # sh 'bats -F junit test/integration/dns/in.thelinuxpro.net/*.bat test/integration/dns/in.thelinuxpro.net/**/*.bat > test/results/integration/TEST-Integration-dns-in_thelinuxpro_net.xml' # } # } # } # post { # always { # archiveArtifacts artifacts: 'test/results/**/*.xml', fingerprint: true # junit 'test/results/**/*.xml' # sh 'rm -rf test/results' # } # } #}