From 3d563cb219dab933a582f062a66ec2e117f67ec5 Mon Sep 17 00:00:00 2001 From: Kameron Kenny <1267885+kkenny@users.noreply.github.com> Date: Wed, 26 Jun 2024 12:46:34 -0400 Subject: [PATCH] build with docker libs --- Jenkinsfile | 69 ++++++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fab9206..8b88114 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,8 @@ pipeline { agent { - label 'pi501.in.thelinuxpro.net' + node { + label 'pi501.in.thelinuxpro.net' + } } stages { @@ -14,41 +16,42 @@ pipeline { } } - stage('Build telegraf') { - steps { - node { - docker.withRegistry('http://docker-registry1.in.thelinuxpro.net:5000') - def dockerfile = 'Dockerfile' - def telegrafImage = docker.build("telegraf:${env.BUILD_ID}", "-f ${dockerfile}") - telegrafImage.push() - telegrafImage.push('latest') - } - } - } - - stage('Create contexts') { - steps { - sh 'docker context ls | grep pi502 || docker context create pi502 --docker "host=ssh://pi502.in.thelinuxpro.net"' - } - } - - stage('Start container') { - steps { - script { - def status_s = sh(returnStatus: true, script: 'grep $(docker --context pi502 compose ps | tail -n1 | awk \'{ print $2 }\') docker-compose.yml') - - if (status_s != 0) { - sh 'docker --context pi502 compose up -d' - sh 'docker --context pi502 compose ps' - } else { - sh 'docker --context pi502 compose down' - sh 'docker --context pi502 compose up -d' - sh 'docker --context pi502 compose ps' + node { + stage('Build telegraf') { + steps { + script { + docker.withRegistry('http://docker-registry1.in.thelinuxpro.net:5000') + def dockerfile = 'Dockerfile' + def telegrafImage = docker.build("telegraf:${env.BUILD_ID}", "-f ${dockerfile}") + telegrafImage.push() + telegrafImage.push('latest') } } } - } + stage('Create contexts') { + steps { + sh 'docker context ls | grep pi502 || docker context create pi502 --docker "host=ssh://pi502.in.thelinuxpro.net"' + } + } + + stage('Start container') { + steps { + script { + def status_s = sh(returnStatus: true, script: 'grep $(docker --context pi502 compose ps | tail -n1 | awk \'{ print $2 }\') docker-compose.yml') + + if (status_s != 0) { + sh 'docker --context pi502 compose up -d' + sh 'docker --context pi502 compose ps' + } else { + sh 'docker --context pi502 compose down' + sh 'docker --context pi502 compose up -d' + sh 'docker --context pi502 compose ps' + } + } + } + } + + } } } -