-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathJenkinsfile
71 lines (66 loc) · 2.55 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
pipeline {
agent any
tools {
maven 'apache-maven-latest'
jdk 'openjdk-jdk11-latest'
}
environment {
EMAIL_TO = "[email protected], [email protected]"
}
stages {
stage ('Build Checkstyle project') {
steps {
dir('codestyle/org.eclipse.emfcloud.checkstyle') {
sh 'mvn clean verify '
}
}
}
stage('Deploy') {
when {
allOf {
branch 'master';
expression {
/* Only trigger the deployment job if files inside the `codestyle/org.eclipse.emfcloud.checkstyle`
are part of the change set.*/
sh(returnStatus: true, script: 'git diff --name-only HEAD^ | grep --quiet "^codestyle/org.eclipse.emfcloud.checkstyle"') == 0
}
}
}
steps {
build job: 'deploy-emfcloud-checkstyle-m2', wait: false
}
}
}
post {
failure {
script {
if (env.BRANCH_NAME == 'master') {
echo "Build result FAILURE: Send email notification to ${EMAIL_TO}"
emailext attachLog: true,
body: 'Job: ${JOB_NAME}<br>Build Number: ${BUILD_NUMBER}<br>Build URL: ${BUILD_URL}',
mimeType: 'text/html', subject: 'Build ${JOB_NAME} (#${BUILD_NUMBER}) FAILURE', to: "${EMAIL_TO}"
}
}
}
unstable {
script {
if (env.BRANCH_NAME == 'master') {
echo "Build result UNSTABLE: Send email notification to ${EMAIL_TO}"
emailext attachLog: true,
body: 'Job: ${JOB_NAME}<br>Build Number: ${BUILD_NUMBER}<br>Build URL: ${BUILD_URL}',
mimeType: 'text/html', subject: 'Build ${JOB_NAME} (#${BUILD_NUMBER}) UNSTABLE', to: "${EMAIL_TO}"
}
}
}
fixed {
script {
if (env.BRANCH_NAME == 'master') {
echo "Build back to normal: Send email notification to ${EMAIL_TO}"
emailext attachLog: false,
body: 'Job: ${JOB_NAME}<br>Build Number: ${BUILD_NUMBER}<br>Build URL: ${BUILD_URL}',
mimeType: 'text/html', subject: 'Build ${JOB_NAME} back to normal (#${BUILD_NUMBER})', to: "${EMAIL_TO}"
}
}
}
}
}