forked from Wikia/design-system
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile-auto-deploy-marker
33 lines (28 loc) · 1.78 KB
/
Jenkinsfile-auto-deploy-marker
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
def issueUrl = "https://api.github.com/repos/Wikia/design-system/issues/${params.pull_num}"
def authHeader = "-H 'Authorization: token ${GITHUB_TOKEN}'"
def contentTypeHeader = "-H 'Content-type: application/json'"
def labels = "${params.labels}"
node('linux') {
try {
stage('Add label to GitHub repo') {
def githubUsername = "WikiaJenkins"
def publishMajorLabel = "publish-major-on-merge"
def publishMinorLabel = "publish-minor-on-merge"
def publishPatchLabel = "publish-patch-on-merge"
def deployDocsLabel = "deploy-docs-on-merge"
if (!labels.contains(publishMinorLabel) && !labels.contains(publishMajorLabel) && !labels.contains(publishPatchLabel)) {
sh "curl -X POST ${authHeader} ${contentTypeHeader} --data '[ \"${publishMinorLabel}\" ]' ${issueUrl}/labels"
def message = "**Watch out!** This PR will start deployment to **artifactory**.\\n \\n If you do not want it, please remove the `publish-minor-on-merge` label to disable it. Keep in mind that this **label will be re-applied if new commits will be added to this PR**."
sh "curl -X POST ${authHeader} ${contentTypeHeader} --data '{ \"body\": \"${message}\"}' ${issueUrl}/comments"
}
if (!labels.contains(deployDocsLabel)) {
sh "curl -X POST ${authHeader} ${contentTypeHeader} --data '[ \"${deployDocsLabel}\" ]' ${issueUrl}/labels"
def message = "**Watch out!** This PR will start **documentation deployment**.\\n \\n If you do not want it, please remove the `deploy-docs-on-merge` label to disable it. Keep in mind that this **label will be re-applied if new commits will be added to this PR**."
sh "curl -X POST ${authHeader} ${contentTypeHeader} --data '{ \"body\": \"${message}\" }' ${issueUrl}/comments"
}
}
} catch (Exception e) {
currentBuild.result = 'FAILURE'
println e
}
}