-
Notifications
You must be signed in to change notification settings - Fork 12
/
JenkinsfileRelease
97 lines (97 loc) · 3.99 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
pipeline {
options {
disableConcurrentBuilds()
}
agent {
docker {
image 'ghcr.io/cloud-taddiken-online/build-java:21-jdk'
args '-v /home/jenkins/caches/restrict-imports/.m2:/home/jenkins/.m2:rw -v /home/jenkins/caches/restrict-imports/.gradle:/tmp/gradle-user-home:rw -v /home/jenkins/.gnupg:/.gnupg:ro'
}
}
environment {
GITHUB = credentials('Github-Username-Pw')
GIT_ASKPASS='./.git-askpass'
RELEASE_GITHUB_TOKEN = credentials('github_registry_release')
BUILD_CACHE = credentials('build_cache')
GRADLE_CACHE = '/tmp/gradle-user-home'
GRADLE_USER_HOME = '/home/jenkins/.gradle'
MAVEN_CONFIG = ''
ORG_GRADLE_PROJECT_ghToken = credentials('github_registry_release')
ORG_GRADLE_PROJECT_sonatype = credentials('SONATYPE_NEXUS')
ORG_GRADLE_PROJECT_signingPassword = credentials('gpg_password')
ORG_GRADLE_PROJECT_base64EncodedAsciiArmoredSigningKey = credentials('gpg_private_key')
GRADLE_PUBLISH_KEY = credentials('gradle_publish_key')
GRADLE_PUBLISH_SECRET = credentials('gradle_publish_secret')
}
parameters {
string(name: 'RELEASE_VERSION', defaultValue: '', description: 'Version to be released')
booleanParam(name: 'RELEASE_DRY_RUN', defaultValue: false, description: 'Whether to push releases to GitHub')
booleanParam(name: 'RELEASE_VERBOSE', defaultValue: false, description: 'Whether to print more verbose logs during release')
booleanParam(name: 'RELEASE_MERGE_BRANCHES', defaultValue: false, description: 'If true, dev branch will be merged and push to main. Disable this for release candidates. No effect when dry run is true')
}
stages {
stage ('Ensure dev branch') {
when {
expression {
return env.BRANCH_NAME != 'develop';
}
}
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('Load Gradle Cache from host') {
steps {
// Copy the Gradle cache from the host, so we can write to it
sh "rsync -a --include /jdks --include /caches --include /wrapper --exclude '/*' ${GRADLE_CACHE}/ ${GRADLE_USER_HOME} || true"
}
}
stage('Quickcheck') {
steps {
withGradle {
sh './gradlew quickCheck'
}
}
}
stage('Unit-tests') {
steps {
withGradle {
sh './gradlew test coveralls'
}
}
}
stage('Func-tests') {
steps {
withGradle {
sh './gradlew functionalTest'
}
}
}
stage('Perform release') {
steps {
withGradle {
sh './gradlew prepareRelease'
sh './gradlew releaseGitLocal'
sh './gradlew pushRelease -Pgradle.publish.key=$GRADLE_PUBLISH_KEY -Pgradle.publish.secret=$GRADLE_PUBLISH_SECRET'
}
}
}
}
post {
success {
// Write updates to the Gradle cache back to the host
sh "rsync -au ${GRADLE_USER_HOME}/jdks ${GRADLE_USER_HOME}/caches ${GRADLE_USER_HOME}/wrapper ${GRADLE_CACHE}/ || true"
}
}
}