|
@@ -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 {
|
|
pipeline {
|
|
agent {
|
|
agent {
|
|
label "swarm"
|
|
label "swarm"
|
|
@@ -14,6 +16,11 @@ pipeline {
|
|
NEWTAG=''
|
|
NEWTAG=''
|
|
}
|
|
}
|
|
parameters {
|
|
parameters {
|
|
|
|
+ choice (
|
|
|
|
+ choices: 'promo-sdk\npromo-seo',
|
|
|
|
+ description: 'Which repo to use?',
|
|
|
|
+ name: 'GIT_REPO'
|
|
|
|
+ )
|
|
string(
|
|
string(
|
|
name: "service_update",
|
|
name: "service_update",
|
|
defaultValue: "info_promo",
|
|
defaultValue: "info_promo",
|
|
@@ -26,6 +33,30 @@ pipeline {
|
|
)
|
|
)
|
|
}
|
|
}
|
|
stages {
|
|
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"){
|
|
stage("Tagging in Git"){
|
|
steps{
|
|
steps{
|
|
withCredentials([sshUserPrivateKey(credentialsId: 'provision', keyFileVariable: 'GIT_SSH_KEY', passphraseVariable: '', usernameVariable: 'GIT_SSH_USERNAME')]) {
|
|
withCredentials([sshUserPrivateKey(credentialsId: 'provision', keyFileVariable: 'GIT_SSH_KEY', passphraseVariable: '', usernameVariable: 'GIT_SSH_USERNAME')]) {
|
|
@@ -59,17 +90,15 @@ pipeline {
|
|
stage("Updating service"){
|
|
stage("Updating service"){
|
|
steps{
|
|
steps{
|
|
script {
|
|
script {
|
|
- for (String item : service_update.split()) {
|
|
|
|
echo "Updating ${item}"
|
|
echo "Updating ${item}"
|
|
try{
|
|
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){
|
|
catch(err){
|
|
echo "Recovering service $item"
|
|
echo "Recovering service $item"
|
|
- sh "DOCKER_HOST=${DHOST} docker service rollback ${item}"
|
|
|
|
|
|
+ sh "DOCKER_HOST=${DHOST} docker service rollback ${SERVICE_NAME}"
|
|
throw err
|
|
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}"
|
|
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}"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|