-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
60 lines (42 loc) · 1.03 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
import groovy.json.JsonSlurper
def branch = env.BRANCH_NAME
node {
catchError {
stage('CheckOut') {
checkout scm
}
stage('Build') {
echo "Running ${env.BUILD_ID} on ${env.JENKINS_URL}."
docker.image('node:latest').inside() {
withEnv(['HOME=.']) {
sh "npm ci"
}
}
}
stage('Lint') {
docker.image('node:latest').inside() {
withEnv(['HOME=.']) {
sh "npm run lint"
}
}
}
stage('Test') {
docker.image('node:latest').inside() {
withEnv(['HOME=.']) {
sh "npm test"
}
}
}
}
// mailIfStatusChanged env.EMAIL_RECIPIENTS
mailIfStatusChanged "[email protected]"
}
//see: https://github.com/triologygmbh/jenkinsfile/blob/4b-scripted/Jenkinsfile
def mailIfStatusChanged(String recipients) {
// Also send "back to normal" emails. Mailer seems to check build result, but SUCCESS is not set at this point.
if (currentBuild.currentResult == 'SUCCESS') {
currentBuild.result = 'SUCCESS'
}
step([$class: 'Mailer', recipients: recipients])
}