build with docker libs

This commit is contained in:
Kameron Kenny 2024-06-26 12:46:34 -04:00
parent e47b588af0
commit 3d563cb219
No known key found for this signature in database
GPG Key ID: E5006629839D2276
1 changed files with 36 additions and 33 deletions

69
Jenkinsfile vendored
View File

@ -1,6 +1,8 @@
pipeline { pipeline {
agent { agent {
label 'pi501.in.thelinuxpro.net' node {
label 'pi501.in.thelinuxpro.net'
}
} }
stages { stages {
@ -14,41 +16,42 @@ pipeline {
} }
} }
stage('Build telegraf') { node {
steps { stage('Build telegraf') {
node { steps {
docker.withRegistry('http://docker-registry1.in.thelinuxpro.net:5000') script {
def dockerfile = 'Dockerfile' docker.withRegistry('http://docker-registry1.in.thelinuxpro.net:5000')
def telegrafImage = docker.build("telegraf:${env.BUILD_ID}", "-f ${dockerfile}") def dockerfile = 'Dockerfile'
telegrafImage.push() def telegrafImage = docker.build("telegraf:${env.BUILD_ID}", "-f ${dockerfile}")
telegrafImage.push('latest') 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'
} }
} }
} }
}
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'
}
}
}
}
}
} }
} }