-
Notifications
You must be signed in to change notification settings - Fork 1
/
JenkinsfileRelease
78 lines (77 loc) · 2.51 KB
/
JenkinsfileRelease
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
pipeline {
agent {
docker {
image 'maven:3.8-jdk-11'
args '-v /home/jenkins/.m2:/var/maven/.m2 -v /home/jenkins/.gnupg:/.gnupg -e MAVEN_CONFIG=/var/maven/.m2 -e MAVEN_OPTS=-Duser.home=/var/maven'
}
}
environment {
GPG_SECRET = credentials('gpg_password')
GITHUB = credentials('Github-Username-Pw')
GITHUB_RELEASE_TOKEN = credentials('github_registry_release')
GIT_ASKPASS='./.git-askpass'
}
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://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 ('Test Spring-Boot Compatibility') {
steps {
script {
def versionsAsString = sh(script: 'mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=compatible-spring-boot-versions -q -DforceStdout', returnStdout:true).trim()
def versionsArray = versionsAsString.split(',')
versionsArray.each {
stage("Verify against Spring-Boot ${it}") {
sh "mvn -B -Prelease -Dgpg.passphrase=${GPG_SECRET} clean verify -Dversion.spring-boot=${it.trim()}"
}
}
}
}
}
stage('Verify Release') {
steps {
sh 'mvn -B -Prelease -Dgpg.passphrase=${GPG_SECRET} verify'
}
}
stage('Update readme') {
steps {
sh 'git add README.md RELEASE_NOTES.md'
sh 'git commit -m "Update README and RELEASE_NOTES"'
}
}
stage('Perform release') {
steps {
sh "mvn -B gitflow:release-finish -DargLine=\"-Prelease -B -Dgpg.passphrase=${GPG_SECRET} -DskipTests\""
}
}
stage('Create GitHub release') {
steps {
sh 'git checkout main'
sh "mvn -B github-release:github-release -Dgithub.release-token=${GITHUB_RELEASE_TOKEN}"
}
}
}
}