mirror of
https://github.com/86Box/86Box.git
synced 2025-01-22 17:22:25 -05:00
Jenkins: Add new method of extracting the current HEAD commit
This commit is contained in:
parent
065366b35b
commit
73281006b1
1 changed files with 39 additions and 21 deletions
60
.ci/Jenkinsfile
vendored
60
.ci/Jenkinsfile
vendored
|
@ -120,19 +120,39 @@ pipeline {
|
|||
|
||||
steps {
|
||||
script {
|
||||
/* Run a dummy git clone on any node to try and save the latest commit regardless of executor status.
|
||||
This avoids a timing issue where HEAD changes between polling and the nodes being available below.
|
||||
I talked to a few people, and we reached the conclusion that reading the polled commit from within
|
||||
the pipeline is not really possible (maybe short of switching to a multi-branch pipeline), so we
|
||||
have to live with this hack, which shortens but doesn't fully eliminate the timing issue's window. */
|
||||
node {
|
||||
/* Ignore exceptions as this is not really critical. */
|
||||
try {
|
||||
gitClone()
|
||||
} catch (e) {}
|
||||
try {
|
||||
cleanWs()
|
||||
} catch (e) {}
|
||||
/* Cursed hack to extract the current HEAD commit from this build's
|
||||
git polling log. This avoids a timing issue where HEAD changes
|
||||
between polling and the nodes being available below. */
|
||||
if (env.GIT_COMMIT == null) {
|
||||
/* This must run on the master node to read the polling log. */
|
||||
node('master') {
|
||||
/* Ignore exceptions as this is not really critical. */
|
||||
try {
|
||||
/* Switch to this build's directory. */
|
||||
dir("${env.JENKINS_HOME}/jobs/${env.JOB_NAME}/builds/${env.BUILD_NUMBER}") {
|
||||
/* Parse polling log. */
|
||||
def pollingLog = readFile file: 'polling.log'
|
||||
def match = pollingLog =~ /Latest remote head revision on [^ ]+ is: ([a-zA-Z0-9]+)/
|
||||
if (match && match[0]) {
|
||||
env.GIT_COMMIT = match[0][1]
|
||||
println "[-] Read git tag [${env.GIT_COMMIT}] from polling log"
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
/* If the polling log parsing fails, run a dummy git clone on any node. */
|
||||
if (env.GIT_COMMIT == null) {
|
||||
node {
|
||||
/* Ignore exceptions again as this is not really critical. */
|
||||
try {
|
||||
gitClone()
|
||||
} catch (e) {}
|
||||
try {
|
||||
cleanWs()
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Create source tarball. */
|
||||
|
@ -187,14 +207,10 @@ pipeline {
|
|||
removeDir('output')
|
||||
|
||||
/* Switch to output directory. */
|
||||
dir('output') {
|
||||
dir("output/${dynarecNames[dynarec]}/$os - ${archNames[arch]}") {
|
||||
/* Run build process. */
|
||||
def packageName = "${env.JOB_BASE_NAME}${dynarecSlugs[dynarec]}${presetSlugs[preset]}-$os-$arch-b${env.BUILD_NUMBER}"
|
||||
dir(dynarecNames[dynarec]) {
|
||||
dir("$os - ${archNames[arch]}") {
|
||||
/* Run build process. */
|
||||
runBuild("-b \"$packageName\" \"$arch\" ${presetFlags[preset]} ${dynarecFlags[dynarec]} -D \"BUILD_TYPE=$BUILD_TYPE\" -D \"EMU_BUILD=build ${env.BUILD_NUMBER}\" -D \"EMU_BUILD_NUM=${env.BUILD_NUMBER}\"")
|
||||
}
|
||||
}
|
||||
runBuild("-b \"$packageName\" \"$arch\" ${presetFlags[preset]} ${dynarecFlags[dynarec]} -D \"BUILD_TYPE=$BUILD_TYPE\" -D \"EMU_BUILD=build ${env.BUILD_NUMBER}\" -D \"EMU_BUILD_NUM=${env.BUILD_NUMBER}\"")
|
||||
|
||||
/* Archive resulting artifacts. */
|
||||
archiveArtifacts artifacts: "**/**/$packageName*"
|
||||
|
@ -223,12 +239,14 @@ pipeline {
|
|||
post {
|
||||
always {
|
||||
script {
|
||||
/* Mark build as failed if any step has failed. */
|
||||
if (anyFailure) {
|
||||
println "[!] Failing build because a build stage failed"
|
||||
currentBuild.result = 'FAILURE'
|
||||
}
|
||||
|
||||
if (!env.JOB_BASE_NAME.contains("TestBuildPleaseIgnore")) {
|
||||
/* Send out build notifications. */
|
||||
if (!env.JOB_BASE_NAME.contains('TestBuildPleaseIgnore')) {
|
||||
try {
|
||||
/* Notify Discord. */
|
||||
def result = currentBuild.currentResult.toLowerCase()
|
||||
|
|
Loading…
Reference in a new issue