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