forked from rtyler/jhipster-sample-app
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathJenkinsfile
157 lines (157 loc) · 5 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
pipeline { //change me
environment {
REL_VERSION = "${(TAG_NAME != null && TAG_NAME.contains('release-')) ? TAG_NAME.drop(TAG_NAME.lastIndexOf('-')+1) : 'M.' + BUILD_NUMBER}"
}
agent none
options {
skipDefaultCheckout()
}
stages {
stage('Checkout') {
agent any
steps {
checkout scm
stash(name: 'ws', includes: '**', excludes: '**/.git/**')
}
}
stage('Build Backend') {
agent {
docker {
image 'maven:3-alpine'
args '-v $HOME/.m2:/root/.m2'
}
}
steps {
unstash 'ws'
sh 'mvn -B -DskipTests=true clean compile package'
stash name: 'war', includes: 'target/**/*'
}
}
stage('Test Backend') {
agent {
docker {
image 'maven:3-alpine'
args '-v $HOME/.m2:/root/.m2'
}
}
steps {
unstash 'ws'
unstash 'war'
sh 'mvn -B test findbugs:findbugs'
}
post {
success {
junit '**/surefire-reports/**/*.xml'
recordIssues minimumSeverity: 'HIGH', tools: [findBugs(pattern: 'target/**/findbugsXml.xml', useRankAsPriority: true)]
}
unstable {
junit '**/surefire-reports/**/*.xml'
recordIssues minimumSeverity: 'HIGH', tools: [findBugs(pattern: 'target/**/findbugsXml.xml', useRankAsPriority: true)]
}
}
}
stage('Test More') {
parallel {
stage('Frontend') {
when {
anyOf {
branch "master"
tag "release-*"
changeset "src/main/webapp/**/*"
}
}
agent {
dockerfile {
args "-v /tmp:/tmp"
dir "docker/gulp"
}
}
steps {
unstash 'ws'
unstash 'war'
sh '. target/scripts/frontEndTests.sh'
}
}
stage('Performance') {
when {
allOf {
anyOf {
branch "master"
tag "release-*"
}
not {
changeRequest()
}
}
}
agent {
docker {
image 'maven:3-alpine'
args '-v $HOME/.m2:/root/.m2'
}
}
steps {
unstash 'ws'
unstash 'war'
sh 'mvn -B gatling:execute'
}
}
}
}
stage('Deploy to Staging') {
agent any
environment {
STAGING_AUTH = credentials('staging')
}
when {
anyOf {
branch "master"
changeRequest target: "master"
not {
buildingTag()
}
}
}
steps {
unstash 'war'
sh '. target/scripts/deploy.sh staging -v $REL_VERSION -u $STAGING_AUTH_USR -p $STAGING_AUTH_PSW'
}
//Post: Send notifications; hipchat, slack, send email etc.
}
stage('Archive') {
agent any
when {
not {
anyOf {
branch "master"
buildingTag()
}
}
}
steps {
unstash 'war'
archiveArtifacts artifacts: 'target/**/*.war', fingerprint: true, allowEmptyArchive: true
}
}
stage('Deploy to Production') {
agent none
environment {
PROD_AUTH = credentials('production')
}
when {
tag "release-*"
}
options {
timeout(15)
}
steps {
input message: 'Deploy to production?', ok: 'Fire zee missiles!'
node ('linux') {
unstash 'war'
sh '. target/scripts/deploy.sh production -v $REL_VERSION -u $PROD_AUTH_USR -p $PROD_AUTH_PSW'
}
}
}
}
//Post: notifications; hipchat, slack, send email etc.
}