|
@@ -59,15 +59,12 @@ pipeline {
|
|
|
steps {
|
|
|
script {
|
|
|
def CLUSTER_TGT
|
|
|
- echo "Cluster is $cluster"
|
|
|
switch (cluster) {
|
|
|
case 'prod':
|
|
|
CLUSTER_TGT=CLUSTER_PROD
|
|
|
- echo "prod - $CLUSTER_TGT"
|
|
|
break
|
|
|
case 'dev':
|
|
|
CLUSTER_TGT=CLUSTER_DEV
|
|
|
- echo "dev - $CLUSTER_TGT"
|
|
|
break
|
|
|
default:
|
|
|
currentBuild.result = 'ABORTED'
|
|
@@ -76,18 +73,18 @@ pipeline {
|
|
|
for (String item : service_update.split()) {
|
|
|
try{
|
|
|
echo "Updating $item, cluster $CLUSTER_TGT"
|
|
|
- withEnv(["service_name=${item}"]) {
|
|
|
+ withEnv(["service_name=${item}","clustername=${CLUSTER_TGT}"]) {
|
|
|
sh '''export DOCKER_CERT_PATH=/run/secrets/swarm
|
|
|
- export DOCKER_HOST=tcp://${CLUSTER_TGT}:2376 DOCKER_TLS_VERIFY=1
|
|
|
+ export DOCKER_HOST=tcp://${clustername}:2376 DOCKER_TLS_VERIFY=1
|
|
|
docker service update ${service_name} --image ${DOCKER_REGISTRY}/iru/${DOCKER_IMAGE}:${NEWTAG}
|
|
|
'''
|
|
|
}
|
|
|
}
|
|
|
catch(err){
|
|
|
echo "Recovering service $item"
|
|
|
- withEnv(["service_name=${item}"]) {
|
|
|
+ withEnv(["service_name=${item}","clustername=${CLUSTER_TGT}"]) {
|
|
|
sh '''export DOCKER_CERT_PATH=/run/secrets/swarm
|
|
|
- export DOCKER_HOST=tcp://${CLUSTER_TGT}:2376 DOCKER_TLS_VERIFY=1
|
|
|
+ export DOCKER_HOST=tcp://${clustername}:2376 DOCKER_TLS_VERIFY=1
|
|
|
docker service rollback ${service_name}
|
|
|
'''
|
|
|
}
|