build with docker libs
This commit is contained in:
parent
e47b588af0
commit
3d563cb219
|
@ -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'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue