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