Skip to content

Commit 76cb0fc

Browse files
committed
Add Jenkinsfile
1 parent 3550523 commit 76cb0fc

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

Jenkinsfile

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
node {
2+
step([$class: 'GitHubSetCommitStatusBuilder'])
3+
4+
// Checkout code
5+
stage 'Checkout'
6+
checkout scm
7+
def pom = readMavenPom()
8+
def projectName = pom.name
9+
def projectVersion = pom.version
10+
11+
// Build & test
12+
stage 'Build'
13+
try {
14+
echo "Building ${projectName} - ${projectVersion}"
15+
mvn "-Dmaven.test.failure.ignore clean verify"
16+
step([$class: 'ArtifactArchiver', artifacts: '**/target/*.jar', fingerprint: true])
17+
step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/*.xml'])
18+
step([$class: 'FindBugsPublisher', pattern: '**/findbugsXml.xml'])
19+
currentBuild.result = 'SUCCESS'
20+
} catch (Exception err) {
21+
currentBuild.result = 'FAILURE'
22+
}
23+
24+
// Notifications
25+
stage 'Notify'
26+
step([$class: 'GitHubCommitNotifier', resultOnFailure: 'FAILURE'])
27+
def color = 'GREEN'
28+
if (!isOK()) {
29+
color = 'RED'
30+
}
31+
hipchatSend color: "${color}",
32+
message: "${projectName} - ${projectVersion} @ ${env.BRANCH_NAME} <a href='${env.BUILD_URL}'>#${env.BUILD_NUMBER}</a> status: ${currentBuild.result}",
33+
room: 'support-room'
34+
}
35+
36+
// Utility functions
37+
38+
def mvn(String goals) {
39+
def mvnHome = tool "maven-3.3.9"
40+
def javaHome = tool "oracle-8u74"
41+
42+
withEnv(["JAVA_HOME=${javaHome}", "PATH+MAVEN=${mvnHome}/bin"]) {
43+
wrap([$class: 'ConfigFileBuildWrapper', managedFiles: [
44+
[fileId: 'org.jenkinsci.plugins.configfiles.maven.MavenSettingsConfig1446135612420', targetLocation: "settings.xml", variable: '']
45+
]]) {
46+
sh "mvn -s settings.xml -B ${goals}"
47+
}
48+
}
49+
}
50+
51+
@com.cloudbees.groovy.cps.NonCPS
52+
def isOK() {
53+
return "SUCCESS".equals(currentBuild.result)
54+
}

0 commit comments

Comments
 (0)