forked from voxbone/zendesk-java-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
72 lines (67 loc) · 1.79 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
#!groovy
def repo = 'zendesk-java-client'
properties(
[
[
$class : 'BuildDiscarderProperty',
strategy: [$class: 'LogRotator', numToKeepStr: '3']
],
pipelineTriggers([pollSCM('H/5 * * * *')]),
disableConcurrentBuilds(),
]
)
@NonCPS
def getProjectKey(repo) {
return repo + '_' + env.BRANCH_NAME.replaceAll("/", "_")
}
def shouldPublish() {
def snapshot = readMavenPom().version.contains('-SNAPSHOT')
if (env.BRANCH_NAME == 'master' && !snapshot)
{
return true
}
else if (env.BRANCH_NAME != 'master' && snapshot)
{
return true
}
return false
}
node('regular') {
stage("Initial clean-up") {
deleteDir()
}
ws("workspace/${getProjectKey(repo)}")
{
try
{
stage("Checkout") {
checkout scm
}
stage("Run UT/IT - ${getProjectKey(repo)}") {
withMaven(options: [artifactsPublisher(disabled: true), dependenciesFingerprintPublisher(disabled: true)], maven: 'maven') {
sh "mvn -T 16C clean install -fae -U -q"
}
}
stage("Publish to nexus - ${getProjectKey(repo)}") {
if (shouldPublish())
{
withMaven(options: [artifactsPublisher(disabled: true), dependenciesFingerprintPublisher(disabled: true)], maven: 'maven') {
sh "mvn clean deploy -DskipTests -fae -U -q -DnexusUrl=${NEXUS_URL}"
}
}
else
{
sh "echo 'Branch ${env.BRANCH_NAME} cannot publish this version of the artifact (only master can publish release version / other branches snapshots)'"
}
}
}
catch(e){
throw e
}
finally {
stage("Cleanup") {
deleteDir()
}
}
}
}