|
@@ -1,3 +1,5 @@
|
|
|
+PROMO_SDK=[ service_name: 'info_promo-sdk', image: 'iru/promo-sdk', repo: 'git@github.com:icruportal/web-sdk-demo.git', dockerfile: 'Dockerfile-promo-sdk' ]
|
|
|
+PROMO_SEO=[ service_name: 'info_promo-seo', image: 'iru/promo-seo', repo: 'git@github.com:icruportal/web-registration.git', dockerfile: 'Dockerfile-promo-seo' ]
|
|
|
pipeline {
|
|
|
agent {
|
|
|
label "swarm"
|
|
@@ -14,6 +16,11 @@ pipeline {
|
|
|
NEWTAG=''
|
|
|
}
|
|
|
parameters {
|
|
|
+ choice (
|
|
|
+ choices: 'promo-sdk\npromo-seo',
|
|
|
+ description: 'Which repo to use?',
|
|
|
+ name: 'GIT_REPO'
|
|
|
+ )
|
|
|
string(
|
|
|
name: "service_update",
|
|
|
defaultValue: "info_promo",
|
|
@@ -26,6 +33,30 @@ pipeline {
|
|
|
)
|
|
|
}
|
|
|
stages {
|
|
|
+ stage("Calculate Variables") {
|
|
|
+ steps {
|
|
|
+ script {
|
|
|
+ switch (GIT_REPO) {
|
|
|
+ case 'promo-sdk':
|
|
|
+ REPO=PROMO_SDK.repo
|
|
|
+ DOCKER_IMAGE=PROMO_SDK.image
|
|
|
+ SERVICE_NAME=PROMO_SDK.service_name
|
|
|
+ DOCKER_FILE=PROMO_SDK.dockerfile
|
|
|
+ break
|
|
|
+ case 'promo-seo':
|
|
|
+ REPO=PROMO_SEO.repo
|
|
|
+ DOCKER_IMAGE=PROMO_SEO.image
|
|
|
+ SERVICE_NAME=PROMO_SEO.service_name
|
|
|
+ DOCKER_FILE=PROMO_SEO.dockerfile
|
|
|
+ break
|
|
|
+ }
|
|
|
+ echo REPO
|
|
|
+ echo DOCKER_IMAGE
|
|
|
+ echo SERVICE_NAME
|
|
|
+ echo DOCKER_FILE
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
stage("Tagging in Git"){
|
|
|
steps{
|
|
|
withCredentials([sshUserPrivateKey(credentialsId: 'provision', keyFileVariable: 'GIT_SSH_KEY', passphraseVariable: '', usernameVariable: 'GIT_SSH_USERNAME')]) {
|
|
@@ -59,17 +90,15 @@ pipeline {
|
|
|
stage("Updating service"){
|
|
|
steps{
|
|
|
script {
|
|
|
- for (String item : service_update.split()) {
|
|
|
echo "Updating ${item}"
|
|
|
try{
|
|
|
- sh "DOCKER_HOST=${DHOST} docker service update ${item} --image ${PROD_REGISTRY}/${DOCKER_IMAGE}:${NEWTAG}"
|
|
|
+ sh "DOCKER_HOST=${DHOST} docker service update ${SERVICE_NAME} --image ${PROD_REGISTRY}/${DOCKER_IMAGE}:${NEWTAG}"
|
|
|
}
|
|
|
catch(err){
|
|
|
echo "Recovering service $item"
|
|
|
- sh "DOCKER_HOST=${DHOST} docker service rollback ${item}"
|
|
|
+ sh "DOCKER_HOST=${DHOST} docker service rollback ${SERVICE_NAME}"
|
|
|
throw err
|
|
|
}
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -88,4 +117,4 @@ pipeline {
|
|
|
body: "<b>ATTENTION!!!</b> <b><br> Jenkins job failed.\n\n <b><br>Project Name:</b> ${env.JOB_NAME} <b><br>\nBuild Number:</b> ${env.BUILD_NUMBER} <b><br>\nURL Build:</b> ${RUN_DISPLAY_URL}"
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+}
|