-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
104 lines (94 loc) · 3.84 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
pipeline {
agent any
environment {
jdk = 'jdk8'
mvn = 'Maven 3'
version = "1.0.${env.BUILD_NUMBER}"
standard_avio_mvn_settings = '3144821b-28b7-414d-99b5-10ce1bee8c09'
}
stages {
stage('Build and unit test') {
steps {
withMaven(jdk: env.jdk,
maven: env.mvn,
mavenSettingsConfig: env.standard_avio_mvn_settings,
// only want to capture artifact if we're deploying (see below)
options: [artifactsPublisher(disabled: true)]) {
mavenSetVersion(env.version)
// would usually use package but we have a multi module interdependent project
quietMaven 'clean install'
}
archiveArtifacts 'cli/target/appassembler/**/*'
}
}
stage('Mutation Test/Site Report') {
steps {
withMaven(jdk: env.jdk,
maven: env.mvn,
mavenSettingsConfig: env.standard_avio_mvn_settings) {
dir('library') {
// simple way to guarantee the mutation test has run before generating the site
quietMaven 'clean test-compile org.pitest:pitest-maven:mutationCoverage groovydoc:generate site'
publishHTML([allowMissing : false,
alwaysLinkToLastBuild: true,
keepAll : true,
reportDir : 'target/site',
reportFiles : 'index.html',
reportName : 'Maven site'])
}
}
}
}
stage('Integration test') {
environment {
ANYPOINT_CREDS = credentials('anypoint-jenkins')
ANYPOINT_CLIENT_CREDS = credentials('anypoint-client-creds-dev')
}
steps {
withMaven(jdk: env.jdk,
maven: env.mvn,
mavenSettingsConfig: env.standard_avio_mvn_settings,
// only want to capture artifact if we're deploying (see below)
options: [artifactsPublisher(disabled: true)]) {
// don't need to run integration tests on other modules (and they are not defined)
dir('library') {
quietMaven "clean test-compile surefire:test@integration-test -Danypoint.username=${env.ANYPOINT_CREDS_USR} -Danypoint.password=${env.ANYPOINT_CREDS_PSW} -Danypoint.client.id=${env.ANYPOINT_CLIENT_CREDS_USR} -Danypoint.client.secret=${env.ANYPOINT_CLIENT_CREDS_PSW}"
}
}
}
options {
// we manipulate apps in the same environment, etc.
lock('anypoint-integration-test')
}
}
stage('Deploy') {
steps {
withMaven(jdk: env.jdk,
maven: env.mvn,
mavenSettingsConfig: env.standard_avio_mvn_settings) {
quietMaven 'clean deploy -DskipTests'
// keeps buildDiscarder from getting rid of stuff we've published
keepBuild()
}
}
when {
branch 'master'
}
}
}
options {
buildDiscarder logRotator(numToKeepStr: '3')
timestamps()
}
post {
always {
cleanWs()
}
failure {
handleError([message: 'Build failed'])
}
unstable {
handleError([message: 'Build failed'])
}
}
}