From 322469f7494ff08b8f050e3a46ca1325c2d9590a Mon Sep 17 00:00:00 2001 From: Andrew Pitt Date: Mon, 6 Jan 2020 14:11:18 -0500 Subject: [PATCH] Another Jenkinsfile update. --- Jenkinsfile | 66 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 26 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6b374d7f0..634184e64 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,8 +22,10 @@ pipeline { echo "Checkout source." git url: "${gitSourceUrl}", branch: "${gitSourceRef}" echo "Read POM info." - pom = readMavenPom file: 'pom.xml' - projectVersion = pom.version + script { + pom = readMavenPom file: 'pom.xml' + projectVersion = pom.version + } } } stage('Build JAR') { @@ -42,11 +44,13 @@ pipeline { } stage('Build Image') { steps { - echo "Build container image." - openshift.withCluster() { + script { + echo "Build container image." + openshift.withCluster() { openshift.withProject('cicd') { - sh "oc start-build ${appName}-s2i-build --from-file=target/app.jar -n cicd --follow" + sh "oc start-build ${appName}-s2i-build --from-file=target/app.jar -n cicd --follow" } + } } } } @@ -66,42 +70,52 @@ pipeline { } stage('Deploy DEV') { steps { - echo "Deploy to DEV." - openshift.withCluster() { - openshift.withProject("${appName}-dev") { - echo "Rolling out to DEV." - def dc = openshift.selector('dc', "${appName}") - dc.rollout().latest() - dc.rollout().status() + script { + echo "Deploy to DEV." + openshift.withCluster() { + openshift.withProject("${appName}-dev") { + echo "Rolling out to DEV." + def dc = openshift.selector('dc', "${appName}") + dc.rollout().latest() + dc.rollout().status() + } } } } } stage('Integration Tests') { - echo "Running Integration tests..." - sh "mvn verify -Pfailsafe" + steps { + echo "Running Integration tests..." + sh "mvn verify -Pfailsafe" + } } stage('Tag UAT') { agent { label 'jenkins-slave-skopeo' } - script { - openshift.withCluster() { - withCredentials([usernamePassword(credentialsId: "${openshift.project()}-quay-creds-secret", usernameVariable: "QUAY_USERNAME", passwordVariable: "QUAY_PASSWORD")]) { - sh "skopeo copy docker://quay.io/${QUAY_USERNAME}/${QUAY_REPOSITORY}:dev docker://quay.io/${QUAY_USERNAME}/${QUAY_REPOSITORY}:uat --src-creds \"$QUAY_USERNAME:$QUAY_PASSWORD\" --dest-creds \"$QUAY_USERNAME:$QUAY_PASSWORD\" --src-tls-verify=false --dest-tls-verify=false" + steps { + script { + openshift.withCluster() { + withCredentials([usernamePassword(credentialsId: "${openshift.project()}-quay-creds-secret", usernameVariable: "QUAY_USERNAME", passwordVariable: "QUAY_PASSWORD")]) { + sh "skopeo copy docker://quay.io/${QUAY_USERNAME}/${QUAY_REPOSITORY}:dev docker://quay.io/${QUAY_USERNAME}/${QUAY_REPOSITORY}:uat --src-creds \"$QUAY_USERNAME:$QUAY_PASSWORD\" --dest-creds \"$QUAY_USERNAME:$QUAY_PASSWORD\" --src-tls-verify=false --dest-tls-verify=false" + } } } - } + } } stage('Deploy UAT') { - echo "Deploy to UAT." - openshift.withCluster() { - openshift.withProject("${appName}-uat") { - echo "Rolling out to UAT." - def dc = openshift.selector('dc', "${appName}") - dc.rollout().latest() - dc.rollout().status() + steps { + script { + echo "Deploy to UAT." + openshift.withCluster() { + openshift.withProject("${appName}-uat") { + echo "Rolling out to UAT." + def dc = openshift.selector('dc', "${appName}") + dc.rollout().latest() + dc.rollout().status() + } } + } } } }