-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathJenkinsFile
87 lines (71 loc) · 2.13 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
properties([
pipelineTriggers([
upstream(
threshold: hudson.model.Result.SUCCESS,
upstreamProjects: '/metaborg/spoofax-releng/master' // build this project after Spoofax-master is built
)
]),
buildDiscarder(logRotator(artifactNumToKeepStr: '3')),
disableConcurrentBuilds() //disableds parallel builds
])
node('spoofax-buildenv-jenkins') {
// In Jenkins, under Tools, add a JDK Installation with:
// - Name: JDK 11
// - JAVA_HOME: /usr/lib/jvm/java-11-openjdk-amd64
// - Install automatically: false
// Ensure the JDK 11 is available in the Spoofax Docker image at the specified path.
jdk = tool name: 'JDK 11'
env.JAVA_HOME = "${jdk}"
try{
notifyBuild('Started')
stage('Echo') {
// Print important variables and versions for debugging purposes.
sh 'env'
sh 'bash --version'
sh 'git --version'
sh 'python3 --version'
sh 'pip3 --version'
sh "$JAVA_HOME/bin/java -version"
sh "$JAVA_HOME/bin/javac -version"
sh 'mvn --version'
}
stage('Checkout') {
checkout scm
sh "git clean -fXd"
}
stage('Build and Test') {
withMaven(
//mavenLocalRepo: "${env.JENKINS_HOME}/m2repos/${env.EXECUTOR_NUMBER}", //http://yellowgrass.org/issue/SpoofaxWithCore/173
mavenLocalRepo: ".repository",
mavenOpts: '-Xmx1G -Xms1G -Xss16m'
){
sh 'mvn -B -U clean verify -DforceContextQualifier=\$(date +%Y%m%d%H%M)'
}
}
stage('Archive') {
archiveArtifacts(
artifacts: 'calc.eclipse.site/target/site/',
excludes: null,
onlyIfSuccessful: true
)
}
stage('Cleanup') {
sh "git clean -fXd"
}
notifyBuild('Succeeded')
} catch (e) {
notifyBuild('Failed')
throw e
}
}
def notifyBuild(String buildStatus) {
def message = """${buildStatus}: ${env.JOB_NAME} [${env.BUILD_NUMBER}] ${env.BUILD_URL}"""
if (buildStatus == 'Succeeded') {
color = 'good'
} else if (buildStatus == 'Failed') {
color = 'danger'
} else {
color = '#4183C4' // Slack blue
}
slackSend (color: color, message: message, channel: '#some-slack-channel')
}