Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 36 additions & 33 deletions builder-reimage/build/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,42 @@ pipeline {
}
}

// Take the node offline BEFORE syncing labels: a newly synced
// label can instantly attract queued builds onto a node that is
// about to be wiped (and still has its pre-reimage disk state).
stage("Prepare Jenkins Node-${machine}") {
if (!params.SKIP_REIMAGE) {
withCredentials([
usernamePassword(
credentialsId: 'jenkins-api-token',
usernameVariable: 'JOB_BUILDER_USER',
passwordVariable: 'JOB_BUILDER_PASS'
)
]) {
withEnv([
"SYNC_MACHINE=${machine}",
"SYNC_TARGET_FQDN=${TARGET_FQDN}",
"SYNC_STATE_FILE=${JENKINS_NODE_STATE_FILE}"
]) {
sh '''#!/bin/bash
set -euo pipefail

echo "[INFO] Preparing Jenkins node state for $SYNC_MACHINE"

python3 builder-reimage/build/jenkins_node_control.py \
--action prepare_for_reimage \
--jenkins_url "$JENKINS_URL" \
--user "$JOB_BUILDER_USER" \
--token "$JOB_BUILDER_PASS" \
--node "$SYNC_TARGET_FQDN" \
--state-file "$SYNC_STATE_FILE" \
--message "Marked temporary offline for builder reimage activity"
'''
}
}
}
}

stage("Sync Labels-${machine}") {
withCredentials([
usernamePassword(
Expand Down Expand Up @@ -143,39 +179,6 @@ pipeline {

}

stage("Prepare Jenkins Node-${machine}") {
if (!params.SKIP_REIMAGE) {
withCredentials([
usernamePassword(
credentialsId: 'jenkins-api-token',
usernameVariable: 'JOB_BUILDER_USER',
passwordVariable: 'JOB_BUILDER_PASS'
)
]) {
withEnv([
"SYNC_MACHINE=${machine}",
"SYNC_TARGET_FQDN=${TARGET_FQDN}",
"SYNC_STATE_FILE=${JENKINS_NODE_STATE_FILE}"
]) {
sh '''#!/bin/bash
set -euo pipefail

echo "[INFO] Preparing Jenkins node state for $SYNC_MACHINE"

python3 builder-reimage/build/jenkins_node_control.py \
--action prepare_for_reimage \
--jenkins_url "$JENKINS_URL" \
--user "$JOB_BUILDER_USER" \
--token "$JOB_BUILDER_PASS" \
--node "$SYNC_TARGET_FQDN" \
--state-file "$SYNC_STATE_FILE" \
--message "Marked temporary offline for builder reimage activity"
'''
}
}
}
}

stage("Reimage-${machine}") {
if (!params.SKIP_REIMAGE) {
withCredentials([string(credentialsId: 'maas-api-key', variable: 'MAAS_API_KEY')]) {
Expand Down