forked from brave/brave-core-crx-packager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
56 lines (51 loc) · 2.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
50
51
52
53
54
55
56
pipeline {
agent none
options {
ansiColor('xterm')
timeout(time: 30, unit: 'MINUTES')
timestamps()
}
stages {
stage('build') {
agent { label 'master' }
steps {
script {
GITHUB_API = 'https://api.github.com/repos/brave'
withCredentials([usernamePassword(credentialsId: 'brave-builds-github-token-for-pr-builder', usernameVariable: 'PR_BUILDER_USER', passwordVariable: 'PR_BUILDER_TOKEN')]) {
def prDetails = readJSON(text: httpRequest(url: GITHUB_API + '/brave-core-crx-packager/pulls?head=brave:' + CHANGE_BRANCH, customHeaders: [[name: 'Authorization', value: 'token ' + PR_BUILDER_TOKEN]]).content)[0]
SKIP = prDetails.labels.count { label -> label.name.equalsIgnoreCase('CI/skip') }.equals(1)
}
if (SKIP) {
echo "Aborting build as PRs are either in draft or have a skip label (CI/skip)"
currentBuild.result = 'ABORTED'
return
}
for (build in Jenkins.instance.getItemByFullName(JOB_NAME).builds) {
if (build.isBuilding() && build.getNumber() < BUILD_NUMBER.toInteger()) {
echo 'Aborting older running build ' + build
build.doStop()
}
}
sh "git fetch origin master"
def modifiedFiles = sh(
script: "git diff --name-only origin/master",
returnStdout: true
).trim().split("\n")
def filePath = 'scripts/packageTorClient.js'
if (!modifiedFiles.contains(filePath)) {
print("No changes detected in ${filePath}")
currentBuild.result = 'SUCCESS'
} else {
def pipelineName = "brave-core-ext-tor-client-update-publish-dev"
def params = [
string(name: "BRANCH", value: env.CHANGE_BRANCH),
booleanParam(name: "UPLOAD", value: false)
]
print("Changes detected in ${filePath}. Running ${pipelineName}")
currentBuild.result = build(job: pipelineName, parameters: params, wait: true, propagate: false).result
}
}
}
}
}
}