-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
111 lines (111 loc) · 3.53 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
pipeline {
options {
buildDiscarder logRotator(numToKeepStr: '3')
}
agent any
stages {
stage("Build and Test") {
agent {
docker {
image "$DOCKER_REGISTRY/oracle/serverjre:8"
registryUrl "https://$DOCKER_REGISTRY/"
registryCredentialsId 'nexus'
}
}
steps {
sh './gradlew wrapper clean build'
}
}
stage("Upload Maven") {
when {
anyOf {
branch 'master';
branch 'acceptance';
branch 'develop'
}
}
steps {
withCredentials(
[
usernamePassword(
credentialsId: 'nexus',
usernameVariable: 'SONATYPE_USERNAME',
passwordVariable: 'SONATYPE_PASSWORD'
)
]
) {
sh "./gradlew wrapper :core:publish :rest:common:publish :rest:client:publish"
}
}
}
stage("Push Docker") {
steps {
withCredentials(
[
usernamePassword(
credentialsId: 'nexus',
usernameVariable: 'DOCKER_REGISTRY_USERNAME',
passwordVariable: 'DOCKER_REGISTRY_PASSWORD'
)
]
) {
sh "./gradlew wrapper --exclude-task test build pushDockerTags --project-prop dockerRegistry=$DOCKER_REGISTRY --project-prop removeImage"
}
}
}
stage("Deploy") {
when {
anyOf {
branch 'acceptance';
branch 'develop'
}
}
steps {
script {
switch (env.BRANCH_NAME) {
case "develop":
environment = "development"
break
case "acceptance":
environment = "acceptance"
break
}
}
build(
job: 'deploy/master',
parameters: [
string(name: 'environment', value: environment),
booleanParam(name: "translation", value: true)
],
propagate: 'true',
wait: 'false'
)
}
}
}
post {
always {
script {
switch (currentBuild.currentResult) {
case "SUCCESS":
color = 'good'
break
case "UNSTABLE":
color = 'warning'
break
case "FAILURE":
color = 'danger'
break
default:
color = '#439FE0'
break
}
}
slackSend(
color: "$color",
message: "Build Finished with ${currentBuild.currentResult} - <${env.BUILD_URL}|${env.JOB_NAME} ${env.BUILD_NUMBER}>",
channel: '#qup-jenkins'
)
}
}
}