-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
100 lines (86 loc) · 2.81 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env groovy
/*
* Jenkinsfile
* JenkinsfileTemplate
*
*
*/
import jenkins.model.*
def MAIL_TO = JenkinsLocationConfiguration.get().getAdminAddress()
echo "MAIL_TO: $MAIL_TO"
properties([
// Don't trigger this job when changes are found from branch indexing.
//overrideIndexTriggers(false),
disableConcurrentBuilds(),
pipelineTriggers([
cron('H 1 * * *')
]),
buildDiscarder(logRotator(numToKeepStr: '100')),
])
// Global variables
String output
try {
timeout(time: 1, unit: 'HOURS') {
withEnv(['LANG=en_US.UTF-8']) {
node {
stage("🛒 Checkout") {
checkout scm
}
stage("📦 Bundler") {
// https://jenkins.io/doc/pipeline/steps/workflow-durable-task-step/#sh-shell-script
sh(
script: "gem list bundler",
label: "💎 List gems"
)
// Capture stdout
output = sh(
script: "which bundle",
label: "❓ Which",
returnStdout: true
).trim()
// Suppress build failure
Integer status = sh(
script: """
false
""",
label: "✔️ Check",
returnStatus: true
)
if (status != 0) {
echo "Aborting build. 😞"
currentBuild.rawBuild.@result = hudson.model.Result.ABORTED
}
}
echo "currentBuild.result: ${currentBuild.result}"
// build.@result = hudson.model.Result.SUCCESS
// build.@result = hudson.model.Result.NOT_BUILT
// build.@result = hudson.model.Result.UNSTABLE
// build.@result = hudson.model.Result.FAILURE
// build.@result = hudson.model.Result.ABORTED
if (currentBuild.result && currentBuild.result != 'SUCCESS') {
return
}
stage("❓ Conditional Stage") {
}
}
}
}
}
catch (Exception ex) {
String jobName = env.JOB_NAME
String buildNumber = env.BUILD_NUMBER
String subject = "👷🏻♂️ [FAILURE] $jobName - Build #$buildNumber"
String body = """$jobName
|Build #${buildNumber} - FAILURE
|
|${env.BUILD_URL}
|
|${ex}
|
|${env.BUILD_URL}console
|""".stripMargin()
mail to: MAIL_TO,
subject: subject,
body: body
throw ex
}