pipeline { agent any environment { SLACK = credentials('slack-notification') } parameters { choice( name: 'EBI_SEARCH_ENDPOINT', choices: ['DEV', 'PRO'], description: 'Which ebi search index to use?' ) choice( name: 'DATABASE', choices: ['PRO', 'DEV', 'TEST', 'HH', 'FB'], description: 'Which database instance to use?' ) gitParameter( branchFilter: 'origin/(.*)', defaultValue: 'master', name: 'BRANCH', type: 'PT_BRANCH', description: 'Name of the branch to test and deploy' ) } stages { stage("deploy") { steps { script { // set DB with the corresponding Secret file (from K8) switch(params.DATABASE) { case 'PRO': env.DB = 'db-pro' break case 'DEV': env.DB = 'db-dev' break case 'TEST': env.DB = 'db-test' break case 'FB': env.DB = 'db-fb' break case 'HH': env.DB = 'db-hh' break } // set SEARCH_INDEX switch(params.EBI_SEARCH_ENDPOINT) { case 'PRO': env.SEARCH_INDEX = 'search-index-prod' break case 'DEV': env.SEARCH_INDEX = 'search-index-dev' break } withCredentials([file(credentialsId: 'HX-WP-Config', variable: 'config')]) { sh """ # update repository git reset --hard git fetch --all git checkout ${params.BRANCH} git pull # send start message on Slack curl -X POST -H 'Content-type: application/json' --data '{"text":"Starting deployment of ${params.BRANCH} in the development namespace - HX cluster"}' $SLACK # clear the cache POD=`/net/isilonP/public/rw/homes/xfm_adm/.jenkins/kubectl --kubeconfig=${config} get pod -l app=memcached -o jsonpath="{.items[0].metadata.name}"` /net/isilonP/public/rw/homes/xfm_adm/.jenkins/kubectl --kubeconfig=${config} exec -it \$POD -- sh -c "echo flush_all | nc localhost 11211" # reinstall everything cd kubernetes/helm /net/isilonP/public/rw/homes/xfm_adm/.jenkins/helm uninstall full-dev --kubeconfig ${config} --namespace dev sleep 10 /net/isilonP/public/rw/homes/xfm_adm/.jenkins/helm upgrade --install full-dev --kubeconfig ${config} --namespace dev --set proxy=proxy-hx,database=${DB},searchIndex=${SEARCH_INDEX},rnacentralBranch=${params.BRANCH} . sleep 10 # send final message on Slack curl -X POST -H 'Content-type: application/json' --data '{"text":"Deployed ${params.BRANCH} in the development namespace - HX cluster. This may take a few more seconds."}' $SLACK """ } } } } } }