forked from cloudbees-oss/zendesk-java-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
54 lines (47 loc) · 1.7 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
node {
step([$class: 'GitHubSetCommitStatusBuilder'])
// Checkout code
stage 'Checkout'
checkout scm
def pom = readMavenPom()
def projectName = pom.name
def projectVersion = pom.version
// Build & test
stage 'Build'
try {
echo "Building ${projectName} - ${projectVersion}"
mvn "-Dmaven.test.failure.ignore clean verify"
step([$class: 'ArtifactArchiver', artifacts: '**/target/*.jar', fingerprint: true])
step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/*.xml'])
step([$class: 'FindBugsPublisher', pattern: '**/findbugsXml.xml'])
currentBuild.result = 'SUCCESS'
} catch (Exception err) {
currentBuild.result = 'FAILURE'
}
// Notifications
stage 'Notify'
step([$class: 'GitHubCommitNotifier', resultOnFailure: 'FAILURE'])
def color = 'GREEN'
if (!isOK()) {
color = 'RED'
}
hipchatSend color: "${color}",
message: "${projectName} - ${projectVersion} @ ${env.BRANCH_NAME} <a href='${env.BUILD_URL}'>#${env.BUILD_NUMBER}</a> status: ${currentBuild.result}",
room: 'support-room'
}
// Utility functions
def mvn(String goals) {
def mvnHome = tool "maven-3.3.9"
def javaHome = tool "oracle-8u74"
withEnv(["JAVA_HOME=${javaHome}", "PATH+MAVEN=${mvnHome}/bin"]) {
wrap([$class: 'ConfigFileBuildWrapper', managedFiles: [
[fileId: 'org.jenkinsci.plugins.configfiles.maven.MavenSettingsConfig1446135612420', targetLocation: "settings.xml", variable: '']
]]) {
sh "mvn -s settings.xml -B ${goals}"
}
}
}
@com.cloudbees.groovy.cps.NonCPS
def isOK() {
return "SUCCESS".equals(currentBuild.result)
}