-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
108 lines (108 loc) · 2.65 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
pipeline
{
parameters
{
booleanParam ( name: 'DEPLOY_SNAPSHOT', defaultValue: false, description: 'when true snapshot is deployed' )
booleanParam ( name: 'BUILD_RELEASE', defaultValue: false, description: 'when true a release is built' )
}
environment
{
MVN_SETTINGS = credentials( 'secret-teslanet-maven-settings.xml' )
GNUPGHOME = '/var/lib/jenkins_keys/.gnupg'
}
agent
{
dockerfile
{
filename 'AgentDockerfile'
args '--network sonar_network --volume jenkins_keys:/var/lib/jenkins_keys --volume "jenkinsagent_m2repo:/home/jenkins/.m2/repository' }
}
options
{
buildDiscarder( logRotator(numToKeepStr: '30' ))
}
stages
{
stage('prepare')
{
when
{
expression { params.BUILD_RELEASE }
}
steps
{
sh '''
git config user.email "[email protected]"
git config user.name "jenkins"
mvn -B -s $MVN_SETTINGS release:clean
'''
}
}
stage('build')
{
steps
{
sh 'mvn -B -s $MVN_SETTINGS clean package -DskipTests'
}
}
stage('verify')
{
when
{
not
{
expression { params.DEPLOY_SNAPSHOT }
}
}
steps
{
sh 'mvn -B -s $MVN_SETTINGS verify sonar:sonar -Psonar'
}
}
stage('verify and deploy')
{
when
{
expression { params.DEPLOY_SNAPSHOT }
}
steps
{
sh 'mvn -B -s $MVN_SETTINGS deploy sonar:sonar -Psonar'
}
}
stage('release-prepare')
{
when
{
expression { params.BUILD_RELEASE }
}
steps
{
sh 'mvn -B -s $MVN_SETTINGS release:prepare'
}
}
stage('release-perform')
{
when
{
expression { params.BUILD_RELEASE }
}
steps
{
sh 'mvn -B -s $MVN_SETTINGS release:perform'
}
}
}
post
{
// Clean after build
always
{
cleanWs( cleanWhenNotBuilt: false,
deleteDirs: true,
disableDeferredWipeout: true,
notFailBuild: true
)
}
}
}