-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathJenkinsfile
95 lines (85 loc) · 4.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
87
88
89
90
91
92
93
94
95
properties([
buildDiscarder(
logRotator(artifactDaysToKeepStr: '60', artifactNumToKeepStr: '3', daysToKeepStr: '60', numToKeepStr: '20')
),
])
/* Init Constants */
String haskellWorkDir="/home/remotejenkins/workspace/haskell-work-dir"
/* Init global variables for later use */
String userId=""
import jenkins.model.CauseOfInterruption.UserInterruption
import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException
timestamps {
// Cancel older builds.
Run previousBuild = currentBuild.rawBuild.getPreviousBuildInProgress()
while (previousBuild != null) {
if (previousBuild.isInProgress()) {
def executor = previousBuild.getExecutor()
if (executor != null) {
echo ">> Aborting older build #${previousBuild.number}"
executor.interrupt(Result.ABORTED, new UserInterruption(
"Aborted by newer build #${currentBuild.number}"
))
}
}
previousBuild = previousBuild.getPreviousBuildInProgress()
}
node ('pipelines') {
try {
stage('build') {
parallel (
failFast: true,
haskellBuild: {
withEnv(["HASKELL_WORK_DIR=${haskellWorkDir}"]) {
sh(script: 'mkdir -p $HASKELL_WORK_DIR')
}
dir(path: "${haskellWorkDir}/") {
def scmVars = checkout([
$class: 'GitSCM',
branches: [[ name: env.CHANGE_BRANCH ]],
userRemoteConfigs: [[credentialsId: '010e0c41-651f-4f83-8706-b5f4281d9e9c', url: '[email protected]:Simspace/avaleryar.git']],
extensions: [[$class: 'CleanBeforeCheckout']],
])
/* Notify committer that job is starting and where */
def committerEmail = sh(script: 'git --no-pager show -s --format="%ae"', returnStdout: true).trim()
userId = slackUserIdFromEmail("$committerEmail")
slackSend(color: 'good', notifyCommitters: true, message: "<@$userId> Your Job has started here: <$BUILD_URL>")
/* Build haskell binaries */
sh '''
# no -Werror until ghc 8.8 is on everywhere
stack test avaleryar avaleryar-repl --ghc-options='-Wall' --fast
# run the benchmarks with a 10-second timeout
stack bench avaleryar --fast --ba '-o ava-benchmarks.html --junit ava-benchmarks.xml --time-limit 10'
'''
junit 'core/ava-benchmarks.xml'
publishHTML(target : [
allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'core',
reportFiles: 'ava-benchmarks.html',
reportName: 'Benchmarks'
])
}
}
)
}
stage('clean-up') {
/* Notify committer that job succeeded */
slackSend(color: 'good', notifyCommitters: true, message: "<@$userId> Your Job has succeeded. : <$BUILD_URL>")
}
// Catches the abort signal, want to skip the input()
} catch(FlowInterruptedException caught) {
stage('clean-up') {
slackSend(color: 'good', notifyCommitters: true, message: "<@$userId> Your Job has been aborted: <$BUILD_URL>")
}
// Catches all other failure reasons
} catch(caught) {
currentBuild.result = "FAILED"
stage('clean-up') {
slackSend(color: 'bad', notifyCommitters: true, message: "<@$userId> Your Job has Failed. Do you want to keep the generated portal for further debugging? <$BUILD_URL>")
}
throw caught
}
}
}