Jenkins: make build chaining more elegant, and add Discord and IRC notifications
This commit is contained in:
55
.ci/Jenkinsfile
vendored
55
.ci/Jenkinsfile
vendored
@@ -15,7 +15,7 @@
|
||||
* Copyright 2021 RichardG.
|
||||
*/
|
||||
|
||||
/* Run this on /script to get all the approvals necessary to sync build numbers across jobs:
|
||||
/* Run this on /script to get all approvals required to sync build numbers across jobs:
|
||||
|
||||
def approval = org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval.get()
|
||||
approval.approveSignature('staticMethod jenkins.model.Jenkins getInstance')
|
||||
@@ -41,7 +41,7 @@ def windowsBuild() {
|
||||
}
|
||||
|
||||
def unixBuild() {
|
||||
sh 'chmod u+x .ci/build.sh && .ci/build.sh'
|
||||
sh 'chmod u+x .ci/build.sh && exec .ci/build.sh'
|
||||
}
|
||||
|
||||
def saveArtifacts() {
|
||||
@@ -50,6 +50,12 @@ def saveArtifacts() {
|
||||
|
||||
def anySuccess = false
|
||||
|
||||
def buildChain = {
|
||||
'86Box': '86Box-Dev',
|
||||
'86Box-Dev': '86Box-Debug',
|
||||
'86Box-TestBuildPleaseIgnore': '86Box-TestBuildPleaseIgnore2'
|
||||
}
|
||||
|
||||
pipeline {
|
||||
agent none
|
||||
|
||||
@@ -62,6 +68,10 @@ pipeline {
|
||||
description: "Used internally to make sure all downstream builds use the same commit. Don't change this.")
|
||||
}
|
||||
|
||||
environment {
|
||||
DISCORD_WEBHOOK_URL = credentials('discord-webhook-url')
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Build Windows') {
|
||||
steps {
|
||||
@@ -99,32 +109,37 @@ pipeline {
|
||||
post {
|
||||
always {
|
||||
script {
|
||||
if (env.JOB_BASE_NAME == '86Box-TestBuildPleaseIgnore') {
|
||||
["${env.JOB_BASE_NAME}2"].each {
|
||||
try {
|
||||
/* Set next build number for this job. */
|
||||
def job = Jenkins.instance.getItem(it)
|
||||
job.nextBuildNumber = env.BUILD_NUMBER as Integer
|
||||
job.saveNextBuildNumber()
|
||||
} catch (Exception e) {
|
||||
println "[!] Could not set next build number for [$it], make sure all the script approvals are in place"
|
||||
}
|
||||
if (buildChain[env.JOB_BASE_NAME]) {
|
||||
def nextJob = buildChain[env.JOB_BASE_NAME]
|
||||
|
||||
/* Trigger this job. */
|
||||
build propagate: false,
|
||||
wait: false,
|
||||
job: it,
|
||||
parameters: [
|
||||
string(name: 'BUILD_TYPE', value: BUILD_TYPE),
|
||||
string(name: 'BRANCH', value: env.GIT_COMMIT)
|
||||
]
|
||||
try {
|
||||
/* Set next build number for this job. */
|
||||
def job = Jenkins.instance.getItem(nextJob)
|
||||
job.nextBuildNumber = env.BUILD_NUMBER as Integer
|
||||
job.saveNextBuildNumber()
|
||||
} catch (Exception e) {
|
||||
println "[!] Could not set next build number for [$nextJob], make sure all required script approvals are in place"
|
||||
}
|
||||
|
||||
/* Trigger this job. */
|
||||
build propagate: false,
|
||||
wait: false,
|
||||
job: nextJob,
|
||||
parameters: [
|
||||
string(name: 'BUILD_TYPE', value: BUILD_TYPE),
|
||||
string(name: 'BRANCH', value: env.GIT_COMMIT)
|
||||
]
|
||||
}
|
||||
|
||||
if (!anySuccess) {
|
||||
println "[!] Failing build because all build stages failed"
|
||||
currentBuild.result = 'FAILURE'
|
||||
}
|
||||
|
||||
if (!env.JOB_BASE_NAME.contains("TestBuildPleaseIgnore")) {
|
||||
discordSend webhookURL: DISCORD_WEBHOOK_URL
|
||||
ircNotify()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user