From 8721fdd2a827a4eaa69a62553871171cc2289cd6 Mon Sep 17 00:00:00 2001 From: Harry Smith Date: Tue, 9 Jun 2020 07:47:29 +0100 Subject: [PATCH 1/5] DWN-33428 : improve open id connect release process --- Jenkinsfile | 102 +++++++++++++++++++++++---- README.md | 8 ++- openid-connect-client/pom.xml | 2 +- openid-connect-common/pom.xml | 2 +- openid-connect-server-webapp/pom.xml | 2 +- openid-connect-server/pom.xml | 2 +- pom.xml | 2 +- uma-server-webapp/pom.xml | 2 +- uma-server/pom.xml | 2 +- 9 files changed, 103 insertions(+), 21 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c52485f93..0ba08b0bd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,5 @@ // -// CTC Auth Jenkins Pipeline +// CTC Open Id Connect Jenkins Pipeline // pipeline { agent any @@ -7,6 +7,13 @@ pipeline { maven 'Maven 3.3.9' jdk 'Java 8' } + environment { + VERSION = '' + NEW_VERSION = '' + } + parameters { + booleanParam(name: 'RELEASE', defaultValue: false, description: 'Release a new version of the open id connect component') + } options { // Only keep 10 builds in total buildDiscarder(logRotator(numToKeepStr:'10', daysToKeepStr:'2')) @@ -15,38 +22,95 @@ pipeline { timestamps() // Prevent concurrent builds - disableConcurrentBuilds(); + disableConcurrentBuilds() } stages { - stage ('1.3.3 Build') { + stage ('Discover Version Number') { + steps { + script { + def pom = readMavenPom file: 'pom.xml' + def currentVersion = pom.getVersion() + echo 'Current Version: ' + currentVersion + + VERSION = currentVersion.substring(0, currentVersion.indexOf('-SNAPSHOT')) + echo 'Release Version: ' + VERSION + + def parts = VERSION.tokenize('-') + echo 'Parts: ' + parts + + def index = parts[1].toInteger() + echo 'Index: ' + index + + parts.remove(1) + NEW_VERSION = parts.join('-') + '-' + (index + 1) + echo 'Next Version: ' + NEW_VERSION + } + } + } + stage ('1.3.3 Release Build') { when { - branch "1.3.x" + expression { + return BRANCH_NAME == "1.3.x" && params.RELEASE + } } steps { - sh "mvn versions:set -DnewVersion=1.3.3.GRESHAM-19" + sh "mvn versions:set -B -DnewVersion=$VERSION" sh "mvn -N versions:update-child-modules" - + script { + sh "git commit --all --message 'Creating Release $VERSION'" + sh "git tag --annotate v$VERSION --message 'Creating Release $VERSION'" + sh "git push origin HEAD:${BRANCH_NAME} --tags" + } timeout(time: 10, unit: 'MINUTES') { - sh "mvn -B -V -U -T4 clean deploy -DaltReleaseDeploymentRepository=releases::default::https://nexus.greshamtech.com/content/repositories/thirdparty/" + withMaven(options: [jUnitPublisher(disabled: true]) { + sh "mvn -B -V -U -T4 clean deploy -DaltReleaseDeploymentRepository=releases::default::https://nexus.greshamtech.com/content/repositories/thirdparty/" + } } } post { - always{ + always { archiveArtifacts caseSensitive: false, onlyIfSuccessful: true, allowEmptyArchive: true, artifacts: 'openid-connect-server-webapp/target/*.war' } + success { + junit '**/target/surefire-reports/**/*.xml' + } } } - stage ('Build') { + stage ('1.3.3 Snapshot Build') { + when { + expression { + return BRANCH_NAME == "1.3.x" && !params.RELEASE + } + } + steps { + timeout(time: 10, unit: 'MINUTES') { + withMaven(options: [jUnitPublisher(disabled: true]) { + sh "mvn -B -V -U -T4 clean deploy -DaltSnapshotDeploymentRepository=snapshots::default::https://nexus.greshamtech.com/content/repositories/third-party-snapshots/" + } + } + } + post { + always { + archiveArtifacts caseSensitive: false, onlyIfSuccessful: true, allowEmptyArchive: true, artifacts: 'openid-connect-server-webapp/target/*.war' + } + success { + junit '**/target/surefire-reports/**/*.xml' + } + } + } + stage ('Feature Branch Build') { when { not { branch "1.3.x" } } steps { - sh "mvn versions:set -DnewVersion=${env.BRANCH_NAME}.GRESHAM-SNAPSHOT" - sh "mvn -N versions:update-child-modules" timeout(time: 10, unit: 'MINUTES') { - sh "mvn -B -V -U -T4 clean deploy -DaltSnapshotDeploymentRepository=snapshots::default::https://nexus.greshamtech.com/content/repositories/third-party-snapshots/" + withMaven(options: [junitPublisher(disabled: true)]) { + sh "mvn versions:set -DnewVersion=${env.BRANCH_NAME}.GRESHAM-SNAPSHOT" + sh "mvn -N versions:update-child-modules" + sh "mvn -B -V -U -T4 clean deploy -DaltSnapshotDeploymentRepository=snapshots::default::https://nexus.greshamtech.com/content/repositories/third-party-snapshots/" + } } } post { @@ -58,6 +122,20 @@ pipeline { } } } + stage ('Bump Development Version') { + when { + expression { + return BRANCH_NAME == '1.3.x' && params.RELEASE + } + } + steps { + script { + sh "mvn versions:set -DnewVersion=${NEW_VERSION}-SNAPSHOT --batch-mode" + sh "git commit --all --message 'New Development Version $NEW_VERSION-SNAPSHOT'" + sh "git push origin HEAD:${BRANCH_NAME}" + } + } + } } post { always { diff --git a/README.md b/README.md index 2c513b0a0..153b12bed 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,10 @@ The authors and key contributors of the project include: Copyright ©2017, [MIT Internet Trust Consortium](http://www.trust.mit.edu/). Licensed under the Apache 2.0 license, for details see `LICENSE.txt`. -## Note for releasing +## Release Process -Releases are made off of branch 1.3.x - the version released used to depend on the Jenkins build number but this is ineffective as the Jenkins history can vanish leaving you back at build number 1. Therefore, in the Jenkinsfile, the version to be released needs altering on line 26 and incrementing by 1. +Here at Gresham, we use this component for a base for the auth server, our developing branch is 1.3.x and any feature branches should be made off of that branch. + +In order to release a new version of the open-id-connect component, run the `Build with Parameters` on Jenkins ticking the release checkbox as part of the build. + +This will release the next release version (the current version less the -SNAPSHOT), run a build with the tests and then bump the 1.3.x branch to the next snapshot version of the repository diff --git a/openid-connect-client/pom.xml b/openid-connect-client/pom.xml index d01d9a40e..22d57a64c 100644 --- a/openid-connect-client/pom.xml +++ b/openid-connect-client/pom.xml @@ -22,7 +22,7 @@ openid-connect-parent org.mitre - 1.3.3-SNAPSHOT + 1.3.3.GRESHAM-20-SNAPSHOT .. openid-connect-client diff --git a/openid-connect-common/pom.xml b/openid-connect-common/pom.xml index 54cc0ef55..f298c1ec0 100644 --- a/openid-connect-common/pom.xml +++ b/openid-connect-common/pom.xml @@ -22,7 +22,7 @@ openid-connect-parent org.mitre - 1.3.3-SNAPSHOT + 1.3.3.GRESHAM-20-SNAPSHOT .. openid-connect-common diff --git a/openid-connect-server-webapp/pom.xml b/openid-connect-server-webapp/pom.xml index 6bc66e4f9..28576fb36 100644 --- a/openid-connect-server-webapp/pom.xml +++ b/openid-connect-server-webapp/pom.xml @@ -21,7 +21,7 @@ org.mitre openid-connect-parent - 1.3.3-SNAPSHOT + 1.3.3.GRESHAM-20-SNAPSHOT openid-connect-server-webapp war diff --git a/openid-connect-server/pom.xml b/openid-connect-server/pom.xml index 1462be27e..d42043494 100644 --- a/openid-connect-server/pom.xml +++ b/openid-connect-server/pom.xml @@ -23,7 +23,7 @@ org.mitre openid-connect-parent - 1.3.3-SNAPSHOT + 1.3.3.GRESHAM-20-SNAPSHOT .. diff --git a/pom.xml b/pom.xml index 98af967d3..e0665cac7 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ 4.0.0 org.mitre openid-connect-parent - 1.3.3-SNAPSHOT + 1.3.3.GRESHAM-20-SNAPSHOT MITREid Connect pom diff --git a/uma-server-webapp/pom.xml b/uma-server-webapp/pom.xml index 8ce3302da..cdb50603c 100644 --- a/uma-server-webapp/pom.xml +++ b/uma-server-webapp/pom.xml @@ -19,7 +19,7 @@ org.mitre openid-connect-parent - 1.3.3-SNAPSHOT + 1.3.3.GRESHAM-20-SNAPSHOT .. uma-server-webapp diff --git a/uma-server/pom.xml b/uma-server/pom.xml index 219161528..d7cbae630 100644 --- a/uma-server/pom.xml +++ b/uma-server/pom.xml @@ -19,7 +19,7 @@ org.mitre openid-connect-parent - 1.3.3-SNAPSHOT + 1.3.3.GRESHAM-20-SNAPSHOT .. uma-server From 5cef73de8a995196838ffa043e0da665601f1c62 Mon Sep 17 00:00:00 2001 From: Harry Smith Date: Tue, 9 Jun 2020 07:54:30 +0100 Subject: [PATCH 2/5] DWN-33428 : fix junitPublisher disabled logic in Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0ba08b0bd..427fe4db7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -62,7 +62,7 @@ pipeline { sh "git push origin HEAD:${BRANCH_NAME} --tags" } timeout(time: 10, unit: 'MINUTES') { - withMaven(options: [jUnitPublisher(disabled: true]) { + withMaven(options: [jUnitPublisher(disabled: true)]) { sh "mvn -B -V -U -T4 clean deploy -DaltReleaseDeploymentRepository=releases::default::https://nexus.greshamtech.com/content/repositories/thirdparty/" } } @@ -84,7 +84,7 @@ pipeline { } steps { timeout(time: 10, unit: 'MINUTES') { - withMaven(options: [jUnitPublisher(disabled: true]) { + withMaven(options: [jUnitPublisher(disabled: true)]) { sh "mvn -B -V -U -T4 clean deploy -DaltSnapshotDeploymentRepository=snapshots::default::https://nexus.greshamtech.com/content/repositories/third-party-snapshots/" } } From 727b62e0143d974b5f9c39138fa7d0d34daa53ea Mon Sep 17 00:00:00 2001 From: Harry Smith Date: Tue, 9 Jun 2020 07:56:53 +0100 Subject: [PATCH 3/5] DWN-33428 : add batch mode to maven commands --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 427fe4db7..398155c1e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -55,7 +55,7 @@ pipeline { } steps { sh "mvn versions:set -B -DnewVersion=$VERSION" - sh "mvn -N versions:update-child-modules" + sh "mvn -N -B versions:update-child-modules" script { sh "git commit --all --message 'Creating Release $VERSION'" sh "git tag --annotate v$VERSION --message 'Creating Release $VERSION'" @@ -107,8 +107,8 @@ pipeline { steps { timeout(time: 10, unit: 'MINUTES') { withMaven(options: [junitPublisher(disabled: true)]) { - sh "mvn versions:set -DnewVersion=${env.BRANCH_NAME}.GRESHAM-SNAPSHOT" - sh "mvn -N versions:update-child-modules" + sh "mvn versions:set -B -DnewVersion=${env.BRANCH_NAME}.GRESHAM-SNAPSHOT" + sh "mvn -N -B versions:update-child-modules" sh "mvn -B -V -U -T4 clean deploy -DaltSnapshotDeploymentRepository=snapshots::default::https://nexus.greshamtech.com/content/repositories/third-party-snapshots/" } } From 7e6ad70daf93c73b68bb2ab5ce7e6cec14dc6fcf Mon Sep 17 00:00:00 2001 From: Harry Smith Date: Tue, 9 Jun 2020 13:01:31 +0100 Subject: [PATCH 4/5] DWN-33428 : review comments to tidy Jenkinsfile --- Jenkinsfile | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 398155c1e..43ac38172 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,3 @@ -// -// CTC Open Id Connect Jenkins Pipeline -// pipeline { agent any tools { @@ -30,20 +27,14 @@ pipeline { script { def pom = readMavenPom file: 'pom.xml' def currentVersion = pom.getVersion() - echo 'Current Version: ' + currentVersion VERSION = currentVersion.substring(0, currentVersion.indexOf('-SNAPSHOT')) - echo 'Release Version: ' + VERSION def parts = VERSION.tokenize('-') - echo 'Parts: ' + parts - - def index = parts[1].toInteger() - echo 'Index: ' + index + def currentGreshamVersion = parts[1].toInteger() parts.remove(1) - NEW_VERSION = parts.join('-') + '-' + (index + 1) - echo 'Next Version: ' + NEW_VERSION + NEW_VERSION = parts.join('-') + '-' + (currentGreshamVersion + 1) } } } @@ -63,14 +54,11 @@ pipeline { } timeout(time: 10, unit: 'MINUTES') { withMaven(options: [jUnitPublisher(disabled: true)]) { - sh "mvn -B -V -U -T4 clean deploy -DaltReleaseDeploymentRepository=releases::default::https://nexus.greshamtech.com/content/repositories/thirdparty/" + sh "mvn -B -V -U -T4 clean deploy -DaltReleaseDeploymentRepository=releases::default::https://nexus.greshamtech.com/repository/thirdparty-maven-releases/" } } } post { - always { - archiveArtifacts caseSensitive: false, onlyIfSuccessful: true, allowEmptyArchive: true, artifacts: 'openid-connect-server-webapp/target/*.war' - } success { junit '**/target/surefire-reports/**/*.xml' } @@ -85,14 +73,11 @@ pipeline { steps { timeout(time: 10, unit: 'MINUTES') { withMaven(options: [jUnitPublisher(disabled: true)]) { - sh "mvn -B -V -U -T4 clean deploy -DaltSnapshotDeploymentRepository=snapshots::default::https://nexus.greshamtech.com/content/repositories/third-party-snapshots/" + sh "mvn -B -V -U -T4 clean deploy -DaltSnapshotDeploymentRepository=snapshots::default::https://nexus.greshamtech.com/repository/thirdparty-maven-snapshots/" } } } post { - always { - archiveArtifacts caseSensitive: false, onlyIfSuccessful: true, allowEmptyArchive: true, artifacts: 'openid-connect-server-webapp/target/*.war' - } success { junit '**/target/surefire-reports/**/*.xml' } @@ -109,14 +94,11 @@ pipeline { withMaven(options: [junitPublisher(disabled: true)]) { sh "mvn versions:set -B -DnewVersion=${env.BRANCH_NAME}.GRESHAM-SNAPSHOT" sh "mvn -N -B versions:update-child-modules" - sh "mvn -B -V -U -T4 clean deploy -DaltSnapshotDeploymentRepository=snapshots::default::https://nexus.greshamtech.com/content/repositories/third-party-snapshots/" + sh "mvn -B -V -U -T4 clean deploy -DaltSnapshotDeploymentRepository=snapshots::default::https://nexus.greshamtech.com/repository/thirdparty-maven-snapshots/" } } } post { - always{ - archiveArtifacts caseSensitive: false, onlyIfSuccessful: true, allowEmptyArchive: true, artifacts: 'openid-connect-server-webapp/target/*.war' - } success { junit '**/target/surefire-reports/**/*.xml' } From f7454492be408cd2f724ed24bc03cf2a9e19a881 Mon Sep 17 00:00:00 2001 From: Harry Smith Date: Tue, 9 Jun 2020 13:02:12 +0100 Subject: [PATCH 5/5] DWN-33428 : convert indents to tabs in Jenkinsfile --- Jenkinsfile | 114 ++++++++++++++++++++++++++-------------------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 43ac38172..5ff4523bd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,5 @@ pipeline { - agent any + agent any tools { maven 'Maven 3.3.9' jdk 'Java 8' @@ -39,69 +39,69 @@ pipeline { } } stage ('1.3.3 Release Build') { - when { - expression { - return BRANCH_NAME == "1.3.x" && params.RELEASE - } - } - steps { - sh "mvn versions:set -B -DnewVersion=$VERSION" - sh "mvn -N -B versions:update-child-modules" + when { + expression { + return BRANCH_NAME == "1.3.x" && params.RELEASE + } + } + steps { + sh "mvn versions:set -B -DnewVersion=$VERSION" + sh "mvn -N -B versions:update-child-modules" script { sh "git commit --all --message 'Creating Release $VERSION'" sh "git tag --annotate v$VERSION --message 'Creating Release $VERSION'" sh "git push origin HEAD:${BRANCH_NAME} --tags" } - timeout(time: 10, unit: 'MINUTES') { - withMaven(options: [jUnitPublisher(disabled: true)]) { - sh "mvn -B -V -U -T4 clean deploy -DaltReleaseDeploymentRepository=releases::default::https://nexus.greshamtech.com/repository/thirdparty-maven-releases/" - } - } - } - post { - success { - junit '**/target/surefire-reports/**/*.xml' - } - } - } - stage ('1.3.3 Snapshot Build') { - when { - expression { - return BRANCH_NAME == "1.3.x" && !params.RELEASE - } - } - steps { - timeout(time: 10, unit: 'MINUTES') { - withMaven(options: [jUnitPublisher(disabled: true)]) { - sh "mvn -B -V -U -T4 clean deploy -DaltSnapshotDeploymentRepository=snapshots::default::https://nexus.greshamtech.com/repository/thirdparty-maven-snapshots/" - } - } - } - post { - success { - junit '**/target/surefire-reports/**/*.xml' - } - } - } + timeout(time: 10, unit: 'MINUTES') { + withMaven(options: [jUnitPublisher(disabled: true)]) { + sh "mvn -B -V -U -T4 clean deploy -DaltReleaseDeploymentRepository=releases::default::https://nexus.greshamtech.com/repository/thirdparty-maven-releases/" + } + } + } + post { + success { + junit '**/target/surefire-reports/**/*.xml' + } + } + } + stage ('1.3.3 Snapshot Build') { + when { + expression { + return BRANCH_NAME == "1.3.x" && !params.RELEASE + } + } + steps { + timeout(time: 10, unit: 'MINUTES') { + withMaven(options: [jUnitPublisher(disabled: true)]) { + sh "mvn -B -V -U -T4 clean deploy -DaltSnapshotDeploymentRepository=snapshots::default::https://nexus.greshamtech.com/repository/thirdparty-maven-snapshots/" + } + } + } + post { + success { + junit '**/target/surefire-reports/**/*.xml' + } + } + } stage ('Feature Branch Build') { when { - not { - branch "1.3.x" - } - } + not { + branch "1.3.x" + } + } steps { timeout(time: 10, unit: 'MINUTES') { withMaven(options: [junitPublisher(disabled: true)]) { sh "mvn versions:set -B -DnewVersion=${env.BRANCH_NAME}.GRESHAM-SNAPSHOT" - sh "mvn -N -B versions:update-child-modules" - sh "mvn -B -V -U -T4 clean deploy -DaltSnapshotDeploymentRepository=snapshots::default::https://nexus.greshamtech.com/repository/thirdparty-maven-snapshots/" - } - } + sh "mvn -N -B versions:update-child-modules" + sh "mvn -B -V -U -T4 clean deploy -DaltSnapshotDeploymentRepository=snapshots::default::https://nexus.greshamtech.com/repository/thirdparty-maven-snapshots/" + } + } } post { - success { - junit '**/target/surefire-reports/**/*.xml' - } + success { + junit '**/target/surefire-reports/**/*.xml' + } } } stage ('Bump Development Version') { @@ -113,15 +113,15 @@ pipeline { steps { script { sh "mvn versions:set -DnewVersion=${NEW_VERSION}-SNAPSHOT --batch-mode" - sh "git commit --all --message 'New Development Version $NEW_VERSION-SNAPSHOT'" - sh "git push origin HEAD:${BRANCH_NAME}" + sh "git commit --all --message 'New Development Version $NEW_VERSION-SNAPSHOT'" + sh "git push origin HEAD:${BRANCH_NAME}" } } } } post { - always { - deleteDir() - } - } + always { + deleteDir() + } + } }