From 2e8fa892c750f1b2213cc14c74186dce5335401c Mon Sep 17 00:00:00 2001 From: Jenkins Date: Tue, 21 Dec 2021 14:25:27 +0000 Subject: [PATCH 1/6] Update for next development version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b7df770..17537e1 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ de.skuzzle.ghpromexporter gh-prom-exporter - 0.0.2 + 0.0.3-SNAPSHOT gh-prom-exporter Export GitHub repository metrics in prometheus format From 4092c99f4d33c1c0c157cea511d9c51b306a7828 Mon Sep 17 00:00:00 2001 From: Simon Taddiken Date: Tue, 21 Dec 2021 15:49:21 +0100 Subject: [PATCH 2/6] Try nested pipeline for release --- JenkinsfileRelease | 120 ++++++++++++++++++++++------------------ RELEASE_NOTES.md | 4 +- readme/RELEASE_NOTES.md | 2 +- 3 files changed, 68 insertions(+), 58 deletions(-) diff --git a/JenkinsfileRelease b/JenkinsfileRelease index c34691b..7d3c83e 100644 --- a/JenkinsfileRelease +++ b/JenkinsfileRelease @@ -1,68 +1,78 @@ pipeline { - agent { - docker { - image 'maven:3.8.3-openjdk-17' - args '-u 1000:999 -v /home/jenkins/.m2:/var/maven/.m2 -v /home/jenkins/.gnupg:/.gnupg -v /var/run/docker.sock:/var/run/docker.sock:ro -e MAVEN_CONFIG=/var/maven/.m2 -e MAVEN_OPTS=-Duser.home=/var/maven' - } - } + agent none environment { - GITHUB = credentials('Github-Username-Pw') DOCKER_REGISTRY = credentials('github_docker_registry') - GITHUB_RELEASE_TOKEN = credentials('github_registry_release') - GIT_ASKPASS='./.git-askpass' - VERSION = 'latest' } stages { - stage ('Ensure dev branch') { - when { - expression { - return env.BRANCH_NAME != 'dev'; + + stage('Build and release') { + + agent { + docker { + image 'maven:3.8.3-openjdk-17' + args '-u 1000:999 -v /home/jenkins/.m2:/var/maven/.m2 -v /home/jenkins/.gnupg:/.gnupg -v /var/run/docker.sock:/var/run/docker.sock:ro -e MAVEN_CONFIG=/var/maven/.m2 -e MAVEN_OPTS=-Duser.home=/var/maven' + } + environment { + GITHUB = credentials('Github-Username-Pw') + GITHUB_RELEASE_TOKEN = credentials('github_registry_release') + GIT_ASKPASS='./.git-askpass' + } + stage ('Ensure dev branch') { + when { + expression { + return env.BRANCH_NAME != 'dev'; + } + } + steps { + error("Releasing is only possible from dev branch") + } + } + stage ('Set Git Information') { + steps { + sh 'echo \'echo \$GITHUB_PSW\' > ./.git-askpass' + sh 'chmod +x ./.git-askpass' + sh 'git config url."https://api@github.com/".insteadOf "https://github.com/"' + sh 'git config url."https://ssh@github.com/".insteadOf "ssh://git@github.com/"' + sh 'git config url."https://git@github.com/".insteadOf "git@github.com:"' + sh 'git config user.email "build@taddiken.online"' + sh 'git config user.name "Jenkins"' + } + } + stage('Create release branch') { + steps { + sh 'mvn -B -Prelease gitflow:release-start' + } + } + stage('Build and push release') { + steps { + sh 'mvn -B -Prelease "-Ddocker.publish.usr=\${DOCKER_REGISTRY_USR}" "-Ddocker.publish.psw=\${DOCKER_REGISTRY_PSW}" -Dspring-boot.build-image.publish=true clean spring-boot:build-image' + } + } + stage('Update readme') { + steps { + sh 'git add README.md RELEASE_NOTES.md' + sh 'git commit -m "Update README and RELEASE_NOTES"' + } + } + stage('Merge release branch') { + steps { + sh "mvn -B gitflow:release-finish" + } + } + stage('Create GitHub release') { + steps { + sh 'git checkout master' + sh "mvn -B github-release:github-release -Dgithub.release-token=${GITHUB_RELEASE_TOKEN}" + } } - } - steps { - error("Releasing is only possible from dev branch") - } - } - stage ('Set Git Information') { - steps { - sh 'echo \'echo \$GITHUB_PSW\' > ./.git-askpass' - sh 'chmod +x ./.git-askpass' - sh 'git config url."https://api@github.com/".insteadOf "https://github.com/"' - sh 'git config url."https://ssh@github.com/".insteadOf "ssh://git@github.com/"' - sh 'git config url."https://git@github.com/".insteadOf "git@github.com:"' - sh 'git config user.email "build@taddiken.online"' - sh 'git config user.name "Jenkins"' - } - } - stage('Create release branch') { - steps { - sh 'mvn -B -Prelease gitflow:release-start' - } - } - stage('Build and push release') { - steps { - sh 'mvn -B -Prelease "-Ddocker.publish.usr=\${DOCKER_REGISTRY_USR}" "-Ddocker.publish.psw=\${DOCKER_REGISTRY_PSW}" -Dspring-boot.build-image.publish=true clean spring-boot:build-image' - } - } - stage('Update readme') { - steps { - sh 'git add README.md RELEASE_NOTES.md' - sh 'git commit -m "Update README and RELEASE_NOTES"' - } - } - stage('Merge release branch') { - steps { - sh "mvn -B gitflow:release-finish" - } - } - stage('Create GitHub release') { - steps { - sh 'git checkout master' - sh "mvn -B github-release:github-release -Dgithub.release-token=${GITHUB_RELEASE_TOKEN}" } } + stage('Deploy to production') { agent any + environment { + VERSION = 'latest' + } steps { sh 'docker login -u ${DOCKER_REGISTRY_USR} -p ${DOCKER_REGISTRY_PSW} ghcr.io' sh 'docker stack deploy --compose-file swarm-stack/production.yml --prune --with-registry-auth gh-prom-exporter' diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 8845ab8..301b33a 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -3,8 +3,8 @@ [![Coverage Status](https://coveralls.io/repos/github/skuzzle/gh-prom-exporter/badge.svg?branch=master)](https://coveralls.io/github/skuzzle/gh-prom-exporter?branch=master) [![Twitter Follow](https://img.shields.io/twitter/follow/skuzzleOSS.svg?style=social)](https://twitter.com/skuzzleOSS) -* Apply correct tags to released image +* Adjust the release process ``` -docker pull ghcr.io/skuzzle/gh-prom-exporter/gh-prom-exporter:0.0.2 +docker pull ghcr.io/skuzzle/gh-prom-exporter/gh-prom-exporter:0.0.3-SNAPSHOT ``` \ No newline at end of file diff --git a/readme/RELEASE_NOTES.md b/readme/RELEASE_NOTES.md index c607e28..69ba265 100644 --- a/readme/RELEASE_NOTES.md +++ b/readme/RELEASE_NOTES.md @@ -3,7 +3,7 @@ [![Coverage Status](https://coveralls.io/repos/github/${github.user}/${github.name}/badge.svg?branch=${github.main-branch})](https://coveralls.io/github/${github.user}/${github.name}?branch=${github.main-branch}) [![Twitter Follow](https://img.shields.io/twitter/follow/skuzzleOSS.svg?style=social)](https://twitter.com/skuzzleOSS) -* Apply correct tags to released image +* Adjust the release process ``` docker pull ${docker.image.name}:${project.version} From 6165857f954e99853bbb2f5d2ebf4e69d8266ff6 Mon Sep 17 00:00:00 2001 From: Simon Taddiken Date: Tue, 21 Dec 2021 15:51:57 +0100 Subject: [PATCH 3/6] Fix braces --- JenkinsfileRelease | 90 +++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/JenkinsfileRelease b/JenkinsfileRelease index 7d3c83e..9ba3c6c 100644 --- a/JenkinsfileRelease +++ b/JenkinsfileRelease @@ -12,58 +12,58 @@ pipeline { image 'maven:3.8.3-openjdk-17' args '-u 1000:999 -v /home/jenkins/.m2:/var/maven/.m2 -v /home/jenkins/.gnupg:/.gnupg -v /var/run/docker.sock:/var/run/docker.sock:ro -e MAVEN_CONFIG=/var/maven/.m2 -e MAVEN_OPTS=-Duser.home=/var/maven' } - environment { - GITHUB = credentials('Github-Username-Pw') - GITHUB_RELEASE_TOKEN = credentials('github_registry_release') - GIT_ASKPASS='./.git-askpass' - } - stage ('Ensure dev branch') { - when { - expression { - return env.BRANCH_NAME != 'dev'; - } - } - steps { - error("Releasing is only possible from dev branch") + } + environment { + GITHUB = credentials('Github-Username-Pw') + GITHUB_RELEASE_TOKEN = credentials('github_registry_release') + GIT_ASKPASS='./.git-askpass' + } + stage ('Ensure dev branch') { + when { + expression { + return env.BRANCH_NAME != 'dev'; } } - stage ('Set Git Information') { - steps { - sh 'echo \'echo \$GITHUB_PSW\' > ./.git-askpass' - sh 'chmod +x ./.git-askpass' - sh 'git config url."https://api@github.com/".insteadOf "https://github.com/"' - sh 'git config url."https://ssh@github.com/".insteadOf "ssh://git@github.com/"' - sh 'git config url."https://git@github.com/".insteadOf "git@github.com:"' - sh 'git config user.email "build@taddiken.online"' - sh 'git config user.name "Jenkins"' - } + steps { + error("Releasing is only possible from dev branch") } - stage('Create release branch') { - steps { - sh 'mvn -B -Prelease gitflow:release-start' - } + } + stage ('Set Git Information') { + steps { + sh 'echo \'echo \$GITHUB_PSW\' > ./.git-askpass' + sh 'chmod +x ./.git-askpass' + sh 'git config url."https://api@github.com/".insteadOf "https://github.com/"' + sh 'git config url."https://ssh@github.com/".insteadOf "ssh://git@github.com/"' + sh 'git config url."https://git@github.com/".insteadOf "git@github.com:"' + sh 'git config user.email "build@taddiken.online"' + sh 'git config user.name "Jenkins"' } - stage('Build and push release') { - steps { - sh 'mvn -B -Prelease "-Ddocker.publish.usr=\${DOCKER_REGISTRY_USR}" "-Ddocker.publish.psw=\${DOCKER_REGISTRY_PSW}" -Dspring-boot.build-image.publish=true clean spring-boot:build-image' - } + } + stage('Create release branch') { + steps { + sh 'mvn -B -Prelease gitflow:release-start' } - stage('Update readme') { - steps { - sh 'git add README.md RELEASE_NOTES.md' - sh 'git commit -m "Update README and RELEASE_NOTES"' - } + } + stage('Build and push release') { + steps { + sh 'mvn -B -Prelease "-Ddocker.publish.usr=\${DOCKER_REGISTRY_USR}" "-Ddocker.publish.psw=\${DOCKER_REGISTRY_PSW}" -Dspring-boot.build-image.publish=true clean spring-boot:build-image' } - stage('Merge release branch') { - steps { - sh "mvn -B gitflow:release-finish" - } + } + stage('Update readme') { + steps { + sh 'git add README.md RELEASE_NOTES.md' + sh 'git commit -m "Update README and RELEASE_NOTES"' } - stage('Create GitHub release') { - steps { - sh 'git checkout master' - sh "mvn -B github-release:github-release -Dgithub.release-token=${GITHUB_RELEASE_TOKEN}" - } + } + stage('Merge release branch') { + steps { + sh "mvn -B gitflow:release-finish" + } + } + stage('Create GitHub release') { + steps { + sh 'git checkout master' + sh "mvn -B github-release:github-release -Dgithub.release-token=${GITHUB_RELEASE_TOKEN}" } } } From bddfc801b3ac26ea42057ef3bbaadb824621c0c3 Mon Sep 17 00:00:00 2001 From: Simon Taddiken Date: Tue, 21 Dec 2021 15:53:13 +0100 Subject: [PATCH 4/6] add missing stages --- JenkinsfileRelease | 81 +++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/JenkinsfileRelease b/JenkinsfileRelease index 9ba3c6c..d86e396 100644 --- a/JenkinsfileRelease +++ b/JenkinsfileRelease @@ -18,56 +18,57 @@ pipeline { GITHUB_RELEASE_TOKEN = credentials('github_registry_release') GIT_ASKPASS='./.git-askpass' } - stage ('Ensure dev branch') { - when { - expression { - return env.BRANCH_NAME != 'dev'; + stages { + stage ('Ensure dev branch') { + when { + expression { + return env.BRANCH_NAME != 'dev'; + } + } + steps { + error("Releasing is only possible from dev branch") } } - steps { - error("Releasing is only possible from dev branch") - } - } - stage ('Set Git Information') { - steps { - sh 'echo \'echo \$GITHUB_PSW\' > ./.git-askpass' - sh 'chmod +x ./.git-askpass' - sh 'git config url."https://api@github.com/".insteadOf "https://github.com/"' - sh 'git config url."https://ssh@github.com/".insteadOf "ssh://git@github.com/"' - sh 'git config url."https://git@github.com/".insteadOf "git@github.com:"' - sh 'git config user.email "build@taddiken.online"' - sh 'git config user.name "Jenkins"' + stage ('Set Git Information') { + steps { + sh 'echo \'echo \$GITHUB_PSW\' > ./.git-askpass' + sh 'chmod +x ./.git-askpass' + sh 'git config url."https://api@github.com/".insteadOf "https://github.com/"' + sh 'git config url."https://ssh@github.com/".insteadOf "ssh://git@github.com/"' + sh 'git config url."https://git@github.com/".insteadOf "git@github.com:"' + sh 'git config user.email "build@taddiken.online"' + sh 'git config user.name "Jenkins"' + } } - } - stage('Create release branch') { - steps { - sh 'mvn -B -Prelease gitflow:release-start' + stage('Create release branch') { + steps { + sh 'mvn -B -Prelease gitflow:release-start' + } } - } - stage('Build and push release') { - steps { - sh 'mvn -B -Prelease "-Ddocker.publish.usr=\${DOCKER_REGISTRY_USR}" "-Ddocker.publish.psw=\${DOCKER_REGISTRY_PSW}" -Dspring-boot.build-image.publish=true clean spring-boot:build-image' + stage('Build and push release') { + steps { + sh 'mvn -B -Prelease "-Ddocker.publish.usr=\${DOCKER_REGISTRY_USR}" "-Ddocker.publish.psw=\${DOCKER_REGISTRY_PSW}" -Dspring-boot.build-image.publish=true clean spring-boot:build-image' + } } - } - stage('Update readme') { - steps { - sh 'git add README.md RELEASE_NOTES.md' - sh 'git commit -m "Update README and RELEASE_NOTES"' + stage('Update readme') { + steps { + sh 'git add README.md RELEASE_NOTES.md' + sh 'git commit -m "Update README and RELEASE_NOTES"' + } } - } - stage('Merge release branch') { - steps { - sh "mvn -B gitflow:release-finish" + stage('Merge release branch') { + steps { + sh "mvn -B gitflow:release-finish" + } } - } - stage('Create GitHub release') { - steps { - sh 'git checkout master' - sh "mvn -B github-release:github-release -Dgithub.release-token=${GITHUB_RELEASE_TOKEN}" + stage('Create GitHub release') { + steps { + sh 'git checkout master' + sh "mvn -B github-release:github-release -Dgithub.release-token=${GITHUB_RELEASE_TOKEN}" + } } } } - stage('Deploy to production') { agent any environment { From a9844652da0d3078452f7fae3984a6972ec32cad Mon Sep 17 00:00:00 2001 From: Jenkins Date: Tue, 21 Dec 2021 14:53:42 +0000 Subject: [PATCH 5/6] Update versions for release --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 17537e1..15cb48d 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ de.skuzzle.ghpromexporter gh-prom-exporter - 0.0.3-SNAPSHOT + 0.0.3 gh-prom-exporter Export GitHub repository metrics in prometheus format From 196f2f206deecce8836947fa32b295f3ef723abc Mon Sep 17 00:00:00 2001 From: Jenkins Date: Tue, 21 Dec 2021 14:55:06 +0000 Subject: [PATCH 6/6] Update README and RELEASE_NOTES --- RELEASE_NOTES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 301b33a..589f66e 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -6,5 +6,5 @@ * Adjust the release process ``` -docker pull ghcr.io/skuzzle/gh-prom-exporter/gh-prom-exporter:0.0.3-SNAPSHOT +docker pull ghcr.io/skuzzle/gh-prom-exporter/gh-prom-exporter:0.0.3 ``` \ No newline at end of file