-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
131 lines (121 loc) · 3.46 KB
/
Jenkinsfile
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// redundant code segments are to be moved into jte functions at a later point in time
pipeline {
agent {
label 'worker'
}
tools {
gradle 'Gradle 7'
}
environment {
// this variable defines which branches will be deployed
SNAPSHOT_BRANCH_REGEX = /(^main$)/
RELEASE_REGEX = /^([0-9]+(\.[0-9]+)*)(-(RC|beta-|alpha-)[0-9]+)?$/
}
stages {
stage('Code Quality: detekt') {
steps {
// setting up a few basic env variables like REPO_NAME and LATEST_AUTHOR
setup_basic_env()
script {
echo REPO_NAME
echo LATEST_AUTHOR
echo LATEST_COMMIT_ID
echo env.BRANCH_NAME
echo env.BUILD_NUMBER
echo env.TAG_NAME
sh 'gradle detekt'
}
}
post {
failure {
rocket_basicsend("*${env.REPO_NAME}*-build nr. ${env.BUILD_NUMBER} *failed* code quality detekt on Branch - ${env.BRANCH_NAME} (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${env.LATEST_AUTHOR}. Review the code!")
}
}
}
stage ('Build fat jar') {
steps {
script {
sh 'gradle bootJar'
}
}
post {
failure {
rocket_buildfail()
}
}
}
stage ('Test') {
steps {
script {
sh 'gradle clean test'
}
}
post {
failure {
rocket_testfail()
}
}
}
// temporarily disabled due to sonarcloud issues
//
// stage ('Reports and Statistics') {
// steps {
// script {
// withSonarQubeEnv('sonarcloud GIScience/ohsome') {
// SONAR_CLI_PARAMETER = ""
// if (env.CHANGE_ID) {
// SONAR_CLI_PARAMETER += " " +
// "-Dsonar.pullrequest.key=${env.CHANGE_ID} " +
// "-Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} " +
// "-Dsonar.pullrequest.base=${env.CHANGE_TARGET}"
// } else {
// SONAR_CLI_PARAMETER += " " +
// "-Dsonar.branch.name=${env.BRANCH_NAME}"
// }
// sh 'gradle sonar ' + SONAR_CLI_PARAMETER
// }
// }
// }
// }
stage ('Deploy Snapshot') {
when {
expression {
return env.BRANCH_NAME ==~ SNAPSHOT_BRANCH_REGEX && VERSION ==~ /.*-SNAPSHOT$/
}
}
steps {
withCredentials([usernamePassword(credentialsId: 'HeiGIT-Nexus', passwordVariable: 'ORG_GRADLE_PROJECT_heigitNexusPassword', usernameVariable: 'ORG_GRADLE_PROJECT_heigitNexusUsername')]) {
script {
env.ORG_GRADLE_PROJECT_repositoryUrl = "https://repo.heigit.org/repository/maven-snapshots/"
sh 'gradle clean publish'
}
}
}
post {
failure {
rocket_snapshotdeployfail()
}
}
}
stage ('Deploy Release') {
when {
expression {
return VERSION ==~ RELEASE_REGEX && env.TAG_NAME ==~ RELEASE_REGEX
}
}
steps {
withCredentials([usernamePassword(credentialsId: 'HeiGIT-Nexus', passwordVariable: 'ORG_GRADLE_PROJECT_heigitNexusPassword', usernameVariable: 'ORG_GRADLE_PROJECT_heigitNexusUsername')]) {
script {
env.ORG_GRADLE_PROJECT_repositoryUrl = "https://repo.heigit.org/repository/maven-releases/"
sh 'gradle clean publish'
}
}
}
post {
failure {
rocket_snapshotdeployfail()
}
}
}
}
}