-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
63 lines (60 loc) · 2.33 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
#!/usr/bin/env groovy
/*
* Jenkinsfile for ansible-eos-vxlan role
*
* Run the Ansible-Role-Test job against a commit or
* pull request in the ansible-eos-vxlan repo
*/
pipeline {
agent { label 'master' }
options {
buildDiscarder(
// Only keep the 20 most recent builds
logRotator(numToKeepStr:'20'))
}
environment {
projectName = 'ansible-eos-vxlan'
emailTo = '[email protected]'
emailFrom = '[email protected]'
}
stages {
stage ('Run tests for ansible-eos-vxlan role') {
when {
// Limit runs to any of these conditions
anyOf {
branch 'master' // master branch
branch 'PR-*' // pull requests
}
}
steps {
// Grab the revision hash and pass it to the test build
sh 'git rev-parse HEAD > revision'
build job: 'Ansible-Role-Test-Starter',
parameters: [
string(name: 'ROLE_NAME', value: 'ansible-eos-vxlan'),
string(name: 'REVISION', value: readFile('revision'))
]
}
post {
// Cleanup and notifications
failure {
// Send an email with a link to logs on failure
mail to: env.emailTo,
from: env.emailFrom,
subject: "${env.projectName} ${env.JOB_NAME} (${env.BUILD_NUMBER}) build failed",
body: "${env.JOB_NAME} (${env.BUILD_NUMBER}) ${env.projectName} build error " +
"is here: ${env.BUILD_URL}\nStarted by ${env.BUILD_CAUSE}"
}
success {
// Send an email notification on success
mail to: env.emailTo,
from: env.emailFrom,
subject: "${env.projectName} ${env.JOB_NAME} (${env.BUILD_NUMBER}) build successful",
body: "${env.JOB_NAME} (${env.BUILD_NUMBER}) ${env.projectName} build successful\n" +
"Started by ${env.BUILD_CAUSE}\n" +
"${env.BUILD_URL}"
}
}
}
}
}