Skip to content

Commit

Permalink
Merge branch 'release/0.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins committed Dec 21, 2021
2 parents ce6501c + 196f2f2 commit 1801e7a
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 57 deletions.
117 changes: 64 additions & 53 deletions JenkinsfileRelease
Original file line number Diff line number Diff line change
@@ -1,68 +1,79 @@
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'
}
}
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://[email protected]/".insteadOf "https://github.com/"'
sh 'git config url."https://[email protected]/".insteadOf "ssh://[email protected]/"'
sh 'git config url."https://[email protected]/".insteadOf "[email protected]:"'
sh 'git config user.email "[email protected]"'
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"
environment {
GITHUB = credentials('Github-Username-Pw')
GITHUB_RELEASE_TOKEN = credentials('github_registry_release')
GIT_ASKPASS='./.git-askpass'
}
}
stage('Create GitHub release') {
steps {
sh 'git checkout master'
sh "mvn -B github-release:github-release -Dgithub.release-token=${GITHUB_RELEASE_TOKEN}"
stages {
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://[email protected]/".insteadOf "https://github.com/"'
sh 'git config url."https://[email protected]/".insteadOf "ssh://[email protected]/"'
sh 'git config url."https://[email protected]/".insteadOf "[email protected]:"'
sh 'git config user.email "[email protected]"'
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'
Expand Down
4 changes: 2 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>de.skuzzle.ghpromexporter</groupId>
<artifactId>gh-prom-exporter</artifactId>
<version>0.0.2</version>
<version>0.0.3</version>

<name>gh-prom-exporter</name>
<description>Export GitHub repository metrics in prometheus format</description>
Expand Down
2 changes: 1 addition & 1 deletion readme/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 1801e7a

Please sign in to comment.