From 17cf9e93160b1aa84a73d1a604a7de806274388f Mon Sep 17 00:00:00 2001 From: Andrew Pitt Date: Thu, 19 Dec 2019 14:04:18 -0500 Subject: [PATCH 01/12] Update Jenkinsfile --- Jenkinsfile | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 769ddfe6b..8a3c839c4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -37,6 +37,17 @@ try { } } } + } + node('jenkins-slave-image-mgmt') { + + stage('Inspect Image') { + sh """ + set +x + + skopeo inspect docker://docker.io/fedora + """ + } + stage("Tag DEV") { echo "Tag image to DEV" openshift.withCluster() { From ff1094d76a08df8239340b05a0ae901355997643 Mon Sep 17 00:00:00 2001 From: Andrew Pitt Date: Thu, 19 Dec 2019 16:23:16 -0500 Subject: [PATCH 02/12] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8a3c839c4..ce25ac742 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -38,7 +38,7 @@ try { } } } - node('jenkins-slave-image-mgmt') { + node('jenkins-slave-skopeo') { stage('Inspect Image') { sh """ From b76bea18a4aef9eadb27531ee64589f9ad4d0326 Mon Sep 17 00:00:00 2001 From: Andrew Pitt Date: Thu, 19 Dec 2019 16:42:53 -0500 Subject: [PATCH 03/12] Update Jenkinsfile --- Jenkinsfile | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ce25ac742..eae8d75a3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,6 +4,8 @@ try { def gitSourceRef=env.GIT_SOURCE_REF def project="" def projectVersion="" + def quayUser=env.QUAY_USER + def quayPassword=env.QUAY_PASSWORD node("maven") { stage("Initialize") { project = env.PROJECT_NAME @@ -40,13 +42,13 @@ try { } node('jenkins-slave-skopeo') { - stage('Inspect Image') { - sh """ - set +x - - skopeo inspect docker://docker.io/fedora - """ + stage('Clair Container Vulnerability Scan') { + steps { + sh "#oc login -u $ocuser -p $ocpass --insecure-skip-tls-verify https://$ocp 2>&1" + + sh 'skopeo --debug copy --src-creds="$(oc whoami)":"$(oc whoami -t)" --src-tls-verify=false --dest-tls-verify=false' + " --dest-creds=$quayUser:$quayPassword docker://docker-registry.default.svc:5000/cicd/spring-petclinic:latest docker://quay.io/$quayUser/spring-petclinic:latest" } + } stage("Tag DEV") { echo "Tag image to DEV" From 3bbff51c6797a791d5a49f13d3c6a191e260322f Mon Sep 17 00:00:00 2001 From: Andrew Pitt Date: Thu, 19 Dec 2019 16:47:43 -0500 Subject: [PATCH 04/12] Update Jenkinsfile --- Jenkinsfile | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index eae8d75a3..5d36dac3b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -42,13 +42,9 @@ try { } node('jenkins-slave-skopeo') { - stage('Clair Container Vulnerability Scan') { - steps { - sh "#oc login -u $ocuser -p $ocpass --insecure-skip-tls-verify https://$ocp 2>&1" - + stage('Clair Container Vulnerability Scan') { sh 'skopeo --debug copy --src-creds="$(oc whoami)":"$(oc whoami -t)" --src-tls-verify=false --dest-tls-verify=false' + " --dest-creds=$quayUser:$quayPassword docker://docker-registry.default.svc:5000/cicd/spring-petclinic:latest docker://quay.io/$quayUser/spring-petclinic:latest" } - } stage("Tag DEV") { echo "Tag image to DEV" From 73361870368b8765ccf800098d716b5bc8a98a98 Mon Sep 17 00:00:00 2001 From: Andrew Pitt Date: Thu, 19 Dec 2019 16:57:39 -0500 Subject: [PATCH 05/12] Update Jenkinsfile --- Jenkinsfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 5d36dac3b..d723057fa 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,6 +6,8 @@ try { def projectVersion="" def quayUser=env.QUAY_USER def quayPassword=env.QUAY_PASSWORD + def ocpUser=env.OCP_USER + def ocpPassword=env.OCP_PASSWORD node("maven") { stage("Initialize") { project = env.PROJECT_NAME @@ -43,6 +45,7 @@ try { node('jenkins-slave-skopeo') { stage('Clair Container Vulnerability Scan') { + sh "oc login -u $ocpUser -p $ocpPassword --insecure-skip-tls-verify https://api.cluster-ottawa-57ac.ottawa-57ac.example.opentlc.com:6443 2>&1" sh 'skopeo --debug copy --src-creds="$(oc whoami)":"$(oc whoami -t)" --src-tls-verify=false --dest-tls-verify=false' + " --dest-creds=$quayUser:$quayPassword docker://docker-registry.default.svc:5000/cicd/spring-petclinic:latest docker://quay.io/$quayUser/spring-petclinic:latest" } From 01ad74128651c71a45e4caea51c3cb3e1a4b1c89 Mon Sep 17 00:00:00 2001 From: Andrew Pitt Date: Fri, 20 Dec 2019 11:40:37 -0500 Subject: [PATCH 06/12] Rename Jenkinsfile to OldJenkinsfile --- Jenkinsfile => OldJenkinsfile | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Jenkinsfile => OldJenkinsfile (100%) diff --git a/Jenkinsfile b/OldJenkinsfile similarity index 100% rename from Jenkinsfile rename to OldJenkinsfile From ccb7dbc607ce5e87034c920964e9750140c9316f Mon Sep 17 00:00:00 2001 From: Andrew Pitt Date: Fri, 20 Dec 2019 11:42:16 -0500 Subject: [PATCH 07/12] Create Jenkinsfile --- Jenkinsfile | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..38dd1eba7 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,63 @@ +try { + def appName=env.APP_NAME + def gitSourceUrl=env.GIT_SOURCE_URL + def gitSourceRef=env.GIT_SOURCE_REF + def project="" + def projectVersion="" + def quayUser=env.QUAY_USER + def quayPassword=env.QUAY_PASSWORD + def ocpUser=env.OCP_USER + def ocpPassword=env.OCP_PASSWORD + + node('jenkins-slave-skopeo') { + + stage('Clair Container Vulnerability Scan') { + sh "oc login -u $ocpUser -p $ocpPassword --insecure-skip-tls-verify https://api.cluster-ottawa-7b89.ottawa-7b89.example.opentlc.com:6443 2>&1" + sh 'skopeo --debug copy --src-creds="$(oc whoami)":"$(oc whoami -t)" --src-tls-verify=false --dest-tls-verify=false' + " --dest-creds=$quayUser:$quayPassword docker://docker-registry.default.svc:5000/cicd/petclinic:latest docker://quay.io/$quayUser/petclinic:latest" + } + + stage("Tag DEV") { + echo "Tag image to DEV" + openshift.withCluster() { + openshift.withProject('cicd') { + openshift.tag("${appName}:latest", "${appName}:dev") + } + } + } + stage("Deploy DEV") { + 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("Tag for QA") { + echo "Tag to UAT" + openshift.withCluster() { + openshift.withProject('cicd') { + openshift.tag("${appName}:dev", "${appName}:uat") + } + } + } + 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() + } + } + } + } +} catch (err) { + echo "in catch block" + echo "Caught: ${err}" + currentBuild.result = 'FAILURE' + throw err +} From e7230591c87348e0f6a2e74c56c947a43408636e Mon Sep 17 00:00:00 2001 From: Andrew Pitt Date: Fri, 20 Dec 2019 11:46:42 -0500 Subject: [PATCH 08/12] Update Jenkinsfile --- Jenkinsfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 38dd1eba7..4dbae68ca 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,13 +5,17 @@ try { def project="" def projectVersion="" def quayUser=env.QUAY_USER - def quayPassword=env.QUAY_PASSWORD + def quayPassword=env.QUAY_PASS def ocpUser=env.OCP_USER - def ocpPassword=env.OCP_PASSWORD + def ocpPassword=env.OCP_PASS node('jenkins-slave-skopeo') { stage('Clair Container Vulnerability Scan') { + echo "Printing ocp and quay users:" + echo "OCP: ${ocpUser}" + echo "Quay: ${quayUser}" + sh "oc login -u $ocpUser -p $ocpPassword --insecure-skip-tls-verify https://api.cluster-ottawa-7b89.ottawa-7b89.example.opentlc.com:6443 2>&1" sh 'skopeo --debug copy --src-creds="$(oc whoami)":"$(oc whoami -t)" --src-tls-verify=false --dest-tls-verify=false' + " --dest-creds=$quayUser:$quayPassword docker://docker-registry.default.svc:5000/cicd/petclinic:latest docker://quay.io/$quayUser/petclinic:latest" } From 37d87f1c01b230c6d5b66ce61a7c9fedf2dde1ba Mon Sep 17 00:00:00 2001 From: Andrew Pitt Date: Fri, 20 Dec 2019 11:55:20 -0500 Subject: [PATCH 09/12] Update Jenkinsfile --- Jenkinsfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4dbae68ca..1660854fc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,17 +4,19 @@ try { def gitSourceRef=env.GIT_SOURCE_REF def project="" def projectVersion="" - def quayUser=env.QUAY_USER - def quayPassword=env.QUAY_PASS - def ocpUser=env.OCP_USER - def ocpPassword=env.OCP_PASS node('jenkins-slave-skopeo') { + def quayUser=env.QUAY_USER + def quayPassword=env.QUAY_PASS + def ocpUser=env.OCP_USER + def ocpPassword=env.OCP_PASS + stage('Clair Container Vulnerability Scan') { echo "Printing ocp and quay users:" echo "OCP: ${ocpUser}" echo "Quay: ${quayUser}" + echo "Git repo: ${gitSourceUrl}" sh "oc login -u $ocpUser -p $ocpPassword --insecure-skip-tls-verify https://api.cluster-ottawa-7b89.ottawa-7b89.example.opentlc.com:6443 2>&1" sh 'skopeo --debug copy --src-creds="$(oc whoami)":"$(oc whoami -t)" --src-tls-verify=false --dest-tls-verify=false' + " --dest-creds=$quayUser:$quayPassword docker://docker-registry.default.svc:5000/cicd/petclinic:latest docker://quay.io/$quayUser/petclinic:latest" From 08a555ab9581210f517b74b8d03974c1113e701e Mon Sep 17 00:00:00 2001 From: Andrew Pitt Date: Fri, 20 Dec 2019 15:24:51 -0500 Subject: [PATCH 10/12] Update Jenkinsfile --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 1660854fc..c6ec9371b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,6 +15,7 @@ try { stage('Clair Container Vulnerability Scan') { echo "Printing ocp and quay users:" echo "OCP: ${ocpUser}" + echo "OCP from env: ${env.OCP_USER}" echo "Quay: ${quayUser}" echo "Git repo: ${gitSourceUrl}" From 0f5fc7da546fe8389eeb89c855b403383c57cad4 Mon Sep 17 00:00:00 2001 From: Andrew Pitt Date: Fri, 20 Dec 2019 16:13:14 -0500 Subject: [PATCH 11/12] Rename Jenkinsfile to TestJenkinsfile --- Jenkinsfile => TestJenkinsfile | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Jenkinsfile => TestJenkinsfile (100%) diff --git a/Jenkinsfile b/TestJenkinsfile similarity index 100% rename from Jenkinsfile rename to TestJenkinsfile From 0911acd3b87fbae080749d61e02d4157204f6eb1 Mon Sep 17 00:00:00 2001 From: Andrew Pitt Date: Fri, 20 Dec 2019 16:14:52 -0500 Subject: [PATCH 12/12] Update and rename OldJenkinsfile to Jenkinsfile --- OldJenkinsfile => Jenkinsfile | 24 ------------------------ 1 file changed, 24 deletions(-) rename OldJenkinsfile => Jenkinsfile (71%) diff --git a/OldJenkinsfile b/Jenkinsfile similarity index 71% rename from OldJenkinsfile rename to Jenkinsfile index d723057fa..c5ea085bb 100644 --- a/OldJenkinsfile +++ b/Jenkinsfile @@ -41,22 +41,6 @@ try { } } } - } - node('jenkins-slave-skopeo') { - - stage('Clair Container Vulnerability Scan') { - sh "oc login -u $ocpUser -p $ocpPassword --insecure-skip-tls-verify https://api.cluster-ottawa-57ac.ottawa-57ac.example.opentlc.com:6443 2>&1" - sh 'skopeo --debug copy --src-creds="$(oc whoami)":"$(oc whoami -t)" --src-tls-verify=false --dest-tls-verify=false' + " --dest-creds=$quayUser:$quayPassword docker://docker-registry.default.svc:5000/cicd/spring-petclinic:latest docker://quay.io/$quayUser/spring-petclinic:latest" - } - - stage("Tag DEV") { - echo "Tag image to DEV" - openshift.withCluster() { - openshift.withProject('cicd') { - openshift.tag("${appName}:latest", "${appName}:dev") - } - } - } stage("Deploy DEV") { echo "Deploy to DEV." openshift.withCluster() { @@ -68,14 +52,6 @@ try { } } } - stage("Tag for QA") { - echo "Tag to UAT" - openshift.withCluster() { - openshift.withProject('cicd') { - openshift.tag("${appName}:dev", "${appName}:uat") - } - } - } stage("Deploy UAT") { echo "Deploy to UAT." openshift.withCluster() {