-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathJenkinsfile-dev
More file actions
238 lines (224 loc) · 10.1 KB
/
Copy pathJenkinsfile-dev
File metadata and controls
238 lines (224 loc) · 10.1 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
// Pipeline for the standalone debugger dev build & test.
//
// This replaces the freestyle "debugger-dev" multi-configuration job.
//
// Three prebuilt deps are dropped into ./artifacts-extern where scripts/build.py finds them:
// * Qt (qt_<os>_*.zip, from Qt/qt-main-pipeline) -- commit-matched
// * LLDB (lldb_<os>_*.zip, from LLVM/llvm-main-pipeline) -- commit-matched
// * binaryninja dev (binaryninja_<os>_*.zip) -- lastSuccessful (latest dev)
//
// Qt and LLDB are commit-matched by reusing the copyExternalArtifactsEx shared library, the
// same one the binaryninja pipeline uses. binja feeds it commits from its llvm-build /
// qt-build submodules; the debugger has no such submodules, so it passes the commits
// explicitly (the qtCommit / llvmCommit params) read from scripts/target_llvm_version.py.
//
// Artifact filters come from the binaryninja repo: Qt/libclang filters from binja's
// Jenkinsfile-dev copyExternalArtifactsEx call, the lldb_<os>_<ver>.zip name from
// llvm-build/build.py, and the BN-dev path from a binaryninja-dev-pipeline artifact URL
// (artifacts/<os>/binaryninja_<os>_<ver>-dev_commercial.zip).
def jobFormatted = "`<${BUILD_URL}|${JOB_NAME} #${BUILD_NUMBER}>`"
slackResponse = null
void updateCommitStatus() {
step([
$class: "GitHubCommitStatusSetter",
reposSource: [$class: "ManuallyEnteredRepositorySource", url: "https://github.com/Vector35/debugger"],
commitShaSource: [$class: "ManuallyEnteredShaSource", sha: "${env.GIT_COMMIT}"],
contextSource: [$class: "ManuallyEnteredCommitContextSource", context: "ci/build"],
errorHandlers: [[$class: "ShallowAnyErrorHandler"]],
statusResultSource: [$class: "DefaultStatusResultSource"],
statusBackrefSource: [$class: "BuildRefBackrefSource"]
]);
}
void doCheckout() {
def maxRetries = 4
def retryDelays = [5, 30, 240] // Delays in seconds: 5s, 30s, 4m
def attempt = 0
while (attempt < maxRetries) {
try {
checkout scmGit(
branches: [[name: "${env.GIT_COMMIT}"]],
extensions: [
[$class: 'MessageExclusion', excludedMessage: '(?s).*skip-ci.*'],
cleanBeforeCheckout(),
cloneOption(noTags: true, reference: '', shallow: false),
submodule(depth: 1, parentCredentials: true, recursiveSubmodules: true, reference: '', shallow: true)
],
userRemoteConfigs: [[
credentialsId: '99e3b07a-7d66-49e6-8f18-9902340537f5',
url: 'git@github.com:Vector35/debugger.git',
name: 'origin',
refspec: '+refs/heads/dev:refs/remotes/origin/dev'
]]
)
return // Success
} catch (Exception e) {
attempt++
if (attempt >= maxRetries) {
echo "Checkout failed after ${maxRetries} attempts"
throw e
}
def retryDelay = retryDelays[attempt - 1]
echo "Checkout failed (attempt ${attempt}/${maxRetries}): ${e.message}"
echo "Retrying in ${retryDelay} seconds..."
sleep(retryDelay)
}
}
}
// Read a `name = "value"` assignment out of scripts/target_llvm_version.py.
String readTarget(String name) {
def text = readFile('scripts/target_llvm_version.py')
def matcher = (text =~ /(?m)^\s*${name}\s*=\s*["']([0-9a-fA-F]+)["']/)
return matcher ? matcher[0][1] : null
}
// Pull the three prebuilt dependencies into ./artifacts-extern for scripts/build.py.
void copyExternalArtifacts(String os) {
// Qt + LLDB -- commit-matched via the shared library. The debugger has no llvm-build /
// qt-build submodules, so we pass the pinned commits explicitly (read from the text file)
// rather than letting copyExternalArtifactsEx derive them from submodule gitlinks.
// The library copies into artifacts-extern/<relativePath> (e.g. artifacts-extern/artifacts/
// qt_<os>_*.zip); build.py looks in both artifacts-extern/ and artifacts-extern/artifacts/.
copyExternalArtifactsEx(
qtJobName: "Qt/qt-main-pipeline",
qtArtifactFilter: "artifacts/qt_${os}_*.zip",
qtCommit: readTarget('qt_build_commit'),
llvmJobName: "LLVM/llvm-main-pipeline",
llvmArtifactFilter: "artifacts/lldb_${os}_*.zip",
llvmCommit: readTarget('llvm_build_commit'),
)
// Binary Ninja dev build -- the debugger builds against the latest dev, so this stays on
// lastSuccessful (not commit-matched). binja publishes one zip per edition under
// artifacts/<os>/, e.g. binaryninja_macosx_5.4.9891-dev_commercial.zip; the _commercial
// suffix selects exactly the commercial edition. build.py globs `binaryninja_*.zip` and
// takes the first hit, so this filter must resolve to a single zip -- it does.
copyArtifacts(
projectName: 'binaryninja-dev-pipeline',
selector: lastSuccessful(),
filter: "artifacts/${os}/binaryninja_${os}_*_commercial.zip",
flatten: true,
fingerprintArtifacts: true,
target: 'artifacts-extern'
)
}
void buildDebugger(String os) {
echo "Build debugger for ${os}"
if (isUnix()) {
sh script: "scripts/build_${os}"
} else {
bat script: "scripts\\build_${os}"
}
}
pipeline {
agent {
label 'master'
}
parameters {
choice(name: 'OS_FILTER', choices: ['all', 'linux', 'linux-arm', 'macosx', 'win64'], description: 'Build for specific os')
}
options {
copyArtifactPermission("*")
buildDiscarder logRotator(artifactDaysToKeepStr: '120', artifactNumToKeepStr: '150', daysToKeepStr: '', numToKeepStr: '')
skipStagesAfterUnstable()
timeout(time: 120, unit: 'MINUTES')
}
environment {
PYTHONUNBUFFERED = '1'
}
stages {
stage('') {
when {
anyOf {
changelog '^((?!skip-ci).)*$'
expression { currentBuild.previousCompletedBuild == null }
triggeredBy cause: "UserIdCause"
}
}
stages {
stage('Start') {
steps {
script {
slackResponse = slackSend(message: "${jobFormatted} started")
}
slackSend channel: slackResponse.threadId, message: "Build started"
updateCommitStatus()
}
}
stage('BuildMatrix') {
matrix {
agent {
label "${os}"
}
when {
anyOf {
expression { params.OS_FILTER == 'all' }
expression { params.OS_FILTER == env.os }
}
}
axes {
axis {
name 'os'
values 'linux', 'linux-arm', 'macosx', 'win64'
}
}
options {
skipDefaultCheckout true
}
stages {
stage("Start") {
steps {
echo "Running on ${NODE_NAME}"
}
}
stage("Checkout") {
steps {
cleanWs()
doCheckout()
}
}
stage("Copy External Artifacts") {
steps {
lock("artifact-cache-${env.NODE_NAME}") {
copyExternalArtifacts(os)
}
}
}
stage("Build") {
steps {
buildDebugger(os)
}
}
}
post {
always {
archiveArtifacts artifacts: 'artifacts/**/*', fingerprint: true, allowEmptyArchive: true
junit testResults: 'test/results.xml', allowEmptyResults: true
}
failure {
slackSend channel: slackResponse.threadId, color: 'danger', message: "debugger-${os} Build Failed"
}
}
}
}
}
post {
always {
updateCommitStatus()
}
success {
slackSend channel: slackResponse.threadId, message: "Build succeeded", color: "good"
slackSend channel: slackResponse.channelId, timestamp: slackResponse.ts, message: ":white_check_mark: ${jobFormatted} succeeded", color: "good"
}
unstable {
slackSend channel: slackResponse.threadId, message: "Build unstable", color: "warning"
slackSend channel: slackResponse.channelId, timestamp: slackResponse.ts, message: ":binja-shake: ${jobFormatted} unstable", color: "warning"
}
failure {
slackSend channel: slackResponse.threadId, message: "Build failed", color: "danger"
slackSend channel: slackResponse.channelId, timestamp: slackResponse.ts, message: ":x: ${jobFormatted} failed", color: "danger"
}
aborted {
slackSend channel: slackResponse.threadId, message: "Build aborted"
}
}
}
}
}