140 lines
3.3 KiB
Groovy
140 lines
3.3 KiB
Groovy
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 {
|
|
sh 'docker build -t docker-registry1.in.thelinuxpro.net:5000/sites/kameronkenny.com:0.0.5 . --push'
|
|
}
|
|
}
|
|
}
|
|
|
|
stage("Tag image as latest") {
|
|
steps {
|
|
script {
|
|
sh 'docker tag docker-registry1.in.thelinuxpro.net:5000/sites/kameronkenny.com:0.0.5 docker-registry1.in.thelinuxpro.net:5000/sites/kameronkenny.com:latest'
|
|
}
|
|
}
|
|
}
|
|
|
|
stage("push latest tag") {
|
|
steps {
|
|
script {
|
|
sh 'docker image push docker-registry1.in.thelinuxpro.net:5000/sites/kameronkenny.com:latest'
|
|
}
|
|
}
|
|
}
|
|
|
|
stage("Create Contexts") {
|
|
steps {
|
|
sh 'docker context ls | grep pi502 || docker context create pi502 --docker "host=ssh://pi502.in.thelinuxpro.net"'
|
|
sh 'docker context ls | grep pi503 || docker context create pi503 --docker "host=ssh://pi503.in.thelinuxpro.net"'
|
|
}
|
|
}
|
|
|
|
stage("Stop pi501 web1 container") {
|
|
steps {
|
|
script {
|
|
def status = sh(returnStatus: true, script: 'grep $(docker compose ps | grep kameronkenny.com_web1 | teail -n1 | awk \'{ print $2 }\') docker-compose.yml')
|
|
|
|
if (status == 0) {
|
|
sh 'docker compose down'
|
|
sh 'sleep 5'
|
|
} else {
|
|
echo 'skip'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
stage("Start pi501 web1 container") {
|
|
steps {
|
|
script {
|
|
def status = sh(returnStatus: true, script: 'grep $(docker compose ps | grep kameronkenny.com_web1 | teail -n1 | awk \'{ print $2 }\') docker-compose.yml')
|
|
|
|
if (status != 0) {
|
|
sh 'docker compose up -d'
|
|
sh 'docker ps'
|
|
} else {
|
|
echo 'skip'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
stage("Stop pi502 web1 container") {
|
|
steps {
|
|
script {
|
|
def status = sh(returnStatus: true, script: 'grep $(docker --context pi502 compose ps | grep kameronkenny.com_web1 | teail -n1 | awk \'{ print $2 }\') docker-compose.yml')
|
|
|
|
if (status == 0) {
|
|
sh 'docker --context pi502 compose down'
|
|
sh 'sleep 5'
|
|
} else {
|
|
echo 'skip'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
stage("Start pi502 web1 container") {
|
|
steps {
|
|
script {
|
|
def status = sh(returnStatus: true, script: 'grep $(docker --context pi502 compose ps | grep kameronkenny.com_web1 | teail -n1 | awk \'{ print $2 }\') docker-compose.yml')
|
|
|
|
if (status != 0) {
|
|
sh 'docker --context pi502 compose up -d'
|
|
sh 'docker --context pi502 ps
|
|
} else {
|
|
echo 'skip'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
stage("Stop pi503 web1 container") {
|
|
steps {
|
|
script {
|
|
def status = sh(returnStatus: true, script: 'grep $(docker --context pi503 compose ps | grep kameronkenny.com_web1 | teail -n1 | awk \'{ print $2 }\') docker-compose.yml')
|
|
|
|
if (status == 0) {
|
|
sh 'docker --context pi503 compose down'
|
|
sh 'sleep 5'
|
|
} else {
|
|
echo 'skip'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
stage("Start pi503 web1 container") {
|
|
steps {
|
|
script {
|
|
def status = sh(returnStatus: true, script: 'grep $(docker --context pi503 compose ps | grep kameronkenny.com_web1 | teail -n1 | awk \'{ print $2 }\') docker-compose.yml')
|
|
|
|
if (status != 0) {
|
|
sh 'docker --context pi503 compose up -d'
|
|
sh 'docker --context pi503 ps
|
|
} else {
|
|
echo 'skip'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|