Merge branch 'develop' of ssh://bitbucket.arbetsformedlingen.se:7999/tea/mina-sidor-fa-web into develop

This commit is contained in:
Erik Tiekstra
2021-09-07 14:44:33 +02:00

View File

@@ -6,6 +6,13 @@ def prod_project = "${PROD_NAMESPACE}"
def jenkinsslave = "nodejs15-agent" def jenkinsslave = "nodejs15-agent"
def dist_path = "dist/apps/mina-sidor-fa" def dist_path = "dist/apps/mina-sidor-fa"
def utilities
def REGISTRY = 'nexus.arbetsformedlingen.se:5555'
def PROJECT_CONTAINING_IMAGES = "app-af-nexus"
def USE_CONFIG_MAP = false
def CONFIG_MAP_KEY = "${appname}-config"
def CONFIG_MAP_PATH = "./openshift/config-maps/${prod_project}.yaml"
pipeline { pipeline {
agent { agent {
@@ -23,6 +30,10 @@ pipeline {
steps { steps {
echo '### Generating build tag... ###' echo '### Generating build tag... ###'
script { script {
def rootDir = pwd()
echo "Current Directory: \"${ rootDir }\""
utilities = load "${ rootDir }/openshift/libs/utilities.groovy"
def packageJson = readJSON file: 'package.json' def packageJson = readJSON file: 'package.json'
BUILD_TAG = "prod_v${packageJson.version}_${env.BUILD_NUMBER}_${CURRENT_COMMIT}" BUILD_TAG = "prod_v${packageJson.version}_${env.BUILD_NUMBER}_${CURRENT_COMMIT}"
echo '### Build tag ###' echo '### Build tag ###'
@@ -163,10 +174,11 @@ pipeline {
echo '### Trying to deploy to prod... ###' echo '### Trying to deploy to prod... ###'
script { script {
openshift.withCluster() { openshift.withCluster() {
def api = "https://pocpconsole.arbetsformedlingen.se:443" utilities.defineAuth()
env.API = sh(script:"set +x; echo ${api}", returnStdout: true).replaceAll(/https?/, 'insecure') // def api = "https://ocpcluster-a.arbetsformedlingen.se:443"
def encodedToken = openshift.selector('secret/imagepromote-token').object().data.tokenbase64 // env.API = sh(script:"set +x; echo ${api}", returnStdout: true).replaceAll(/https?/, 'insecure')
env.TOKEN = sh(script:"set +x; echo ${encodedToken} | base64 --decode", returnStdout: true) // def encodedToken = openshift.selector('secret/imagepromote-token').object().data.tokenbase64
// env.TOKEN = sh(script:"set +x; echo ${encodedToken} | base64 --decode", returnStdout: true)
} }
openshift.withCluster( env.API, env.TOKEN ) { openshift.withCluster( env.API, env.TOKEN ) {
@@ -174,10 +186,12 @@ pipeline {
// Wait for approval // Wait for approval
timeout(time:1440, unit:'MINUTES') { timeout(time:1440, unit:'MINUTES') {
input message: "Go Live with ${ appname } in Production?", ok: "Confirm" input message: "Go Live with ${ appname } in Production?", ok: "Confirm"
openshift.raw("tag nexus.arbetsformedlingen.se:5555/app-af-nexus/${ appname }:${BUILD_TAG} ${appname}:${BUILD_TAG} --insecure") def label = "${ env.BUILD_NUMBER }"
openshift.raw("tag ${ appname }:latest ${ appname }:${BUILD_TAG}") utilities.rollout("${ appname }", "${ appname }", "latest", label, PROJECT_CONTAINING_IMAGES, REGISTRY, USE_CONFIG_MAP, "${ CONFIG_MAP_KEY }", CONFIG_MAP_PATH)
openshift.raw("set image dc/${ appname } ${ appname }=nexus.arbetsformedlingen.se:5555/app-af-nexus/${ appname }:${BUILD_TAG} --record=true --source=docker") //openshift.raw("tag nexus.arbetsformedlingen.se:5555/app-af-nexus/${ appname }:${BUILD_TAG} ${appname}:${BUILD_TAG} --insecure")
openshift.selector("dc", "${ appname }").rollout().status(); //openshift.raw("tag ${ appname }:latest ${ appname }:${BUILD_TAG}")
//openshift.raw("set image dc/${ appname } ${ appname }=nexus.arbetsformedlingen.se:5555/app-af-nexus/${ appname }:${BUILD_TAG} --record=true --source=docker")
//openshift.selector("dc", "${ appname }").rollout().status();
echo '### Deployed to prod! ###' echo '### Deployed to prod! ###'
} }
} }