This repository has been archived by the owner on Oct 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
49 lines (43 loc) · 1.56 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
/*
There is no need to edit this file.
All names are dynamically generated.
*/
// def getRepoURL() {
// sh "git config --get remote.origin.url > .git/remote-url"
// return readFile(".git/remote-url").trim()
// }
// def getCommitSha() {
// sh "git rev-parse HEAD > .git/current-commit"
// return readFile(".git/current-commit").trim()
// }
void setBuildStatus(String message, String context, String state) {
withCredentials([string(credentialsId: '227fd6ff-4a49-40da-98d4-f6da7987f068', variable: 'TOKEN')]) {
// 'set -x' for debugging. Don't worry the access token won't be actually logged
// Also, the sh command actually executed is not properly logged, it will be further escaped when written to the log
sh """
set -x
curl \"https://api.github.com/repos/org/repo/statuses/${env.GIT_COMMIT}?access_token=$TOKEN\" \
-H \"Content-Type: application/json\" \
-X POST \
-d \"{\\\"description\\\": \\\"$message\\\", \\\"state\\\": \\\"$state\\\", \\\"context\\\": \\\"$context\\\", \\\"target_url\\\": \\\"$BUILD_URL\\\"}\"
"""
}
}
pipeline {
agent any
stages {
stage('Compilation') {
steps {
sh "docker build -t ${env.JOB_NAME}:${env.GIT_COMMIT} .".toLowerCase().replace("%2f", "/")
}
}
}
post {
success {
setBuildStatus("Build complete", "compile", "success")
}
failure {
setBuildStatus("Failed", "pl-compile", "failure")
}
}
}