-
Notifications
You must be signed in to change notification settings - Fork 4
/
Jenkinsfile
60 lines (57 loc) · 1.8 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
#!groovy
pipeline {
agent any
// save some io during the build
options {
durabilityHint( 'PERFORMANCE_OPTIMIZED' )
buildDiscarder logRotator( numToKeepStr: '15' )
}
stages {
stage( "Build Website" ) {
agent { node { label 'linux' } }
steps {
timeout( time: 120, unit: 'MINUTES' ) {
withEnv(["JAVA_HOME=${tool 'jdk21'}",
"PATH+MAVEN=${env.JAVA_HOME}/bin:${tool 'maven3'}/bin",
"MAVEN_OPTS=-Xms2g -Xmx4g -Djava.awt.headless=true"]) {
sh "bash ./jetty-website.sh --follow-log --user-sudo jenkins --directive stage -u ''"
publishHTML (target : [allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'target/stage',
reportFiles: 'index.html',
reportName: 'Jetty site',
reportTitles: 'Jetty site'])
}
}
}
}
}
post {
failure {
slackNotif()
}
unstable {
slackNotif()
}
fixed {
slackNotif()
}
}
}
def slackNotif() {
script {
try {
//BUILD_USER = currentBuild.rawBuild.getCause(Cause.UserIdCause).getUserId()
// by ${BUILD_USER}
COLOR_MAP = ['SUCCESS': 'good', 'FAILURE': 'danger', 'UNSTABLE': 'danger', 'ABORTED': 'danger']
slackSend channel: '#jenkins',
color: COLOR_MAP[currentBuild.currentResult],
message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} - ${env.BUILD_URL}"
} catch (Exception e) {
e.printStackTrace()
echo "skip failure slack notification: " + e.getMessage()
}
}
}
// vim: et:ts=2:sw=2:ft=groovy