-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathJenkinsfile
62 lines (50 loc) · 1.79 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
node {
withCredentials([string(credentialsId: 'boundlessgeoadmin-token', variable: 'GITHUB_TOKEN')]) {
currentBuild.result = "SUCCESS"
try {
stage('Checkout'){
checkout scm
echo "Running ${env.BUILD_ID} on ${env.JENKINS_URL}"
}
stage('Package'){
// make build
sh """
docker run -v \$(pwd -P):/code \
-w /code quay.io/boundlessgeo/schema bash \
-c './script/java.sh && \
./script/objc.sh && \
./script/python.sh'
"""
// ./script/golang.sh should NOT be added here ^
// golang pulls the repository, so go source must be committed to the repo
}
}
catch (err) {
currentBuild.result = "FAILURE"
throw err
} finally {
// Success or failure, always send notifications
echo currentBuild.result
notifyBuild(currentBuild.result)
}
}
}
// Slack Integration
def notifyBuild(String buildStatus = currentBuild.result) {
// generate a custom url to use the blue ocean endpoint
def jobName = "${env.JOB_NAME}".split('/')
def repo = jobName[0]
def pipelineUrl = "${env.JENKINS_URL}blue/organizations/jenkins/${repo}/detail/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/pipeline"
// Default values
def colorName = 'RED'
def colorCode = '#FF0000'
def subject = "${buildStatus}\nJob: ${env.JOB_NAME}\nBuild: ${env.BUILD_NUMBER}\nJenkins: ${pipelineUrl}\n"
def summary = (env.CHANGE_ID != null) ? "${subject}\nAuthor: ${env.CHANGE_AUTHOR}\n${env.CHANGE_URL}\n" : "${subject}"
// Override default values based on build status
if (buildStatus == 'SUCCESS') {
colorName = 'GREEN'
colorCode = '#228B22'
}
// Send notifications
slackSend (color: colorCode, message: summary)
}