-
Notifications
You must be signed in to change notification settings - Fork 11
/
Jenkinsfile
53 lines (52 loc) · 1.37 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
def slackBuildFailure (stage) {
slackSend channel: "${env.NOTIFY_CHANNEL}",
color: 'danger',
message: "<!here> Error in job <${env.BLUE_URL}|${env.JOB_NAME} #${env.BUILD_NUMBER}> stage ${stage} build."
}
pipeline {
agent {
node {
label ''
customWorkspace "${env.JOB_NAME}/${env.BUILD_NUMBER}"
}
}
options {
skipDefaultCheckout()
}
parameters {
string(name: 'NOTIFY_CHANNEL', defaultValue: '#ci-notification', description: 'Slack channel to send notifications to.')
string(name: 'TAG', defaultValue: 'master', description: 'A specific sha or branch to build.')
}
environment {
BLUE_URL = "${env.JENKINS_URL}blue/organizations/jenkins/${env.JOB_NAME}/detail/${env.JOB_NAME}/${env.BUILD_NUMBER}/pipeline"
}
stages {
stage('Checkout') {
steps {
checkout scm
sh('git checkout $TAG')
}
}
stage('TestUnit') {
steps {
sh './bin/test'
}
post {
failure {
slackBuildFailure('TestUnit')
}
}
}
}
post {
aborted {
deleteDir()
}
success {
deleteDir()
}
failure {
deleteDir()
}
}
}