ci: recover sudo-owned build metadata
This commit is contained in:
Vendored
+17
@@ -55,6 +55,19 @@ pipeline {
|
|||||||
stages {
|
stages {
|
||||||
stage('Checkout') {
|
stage('Checkout') {
|
||||||
steps {
|
steps {
|
||||||
|
withCredentials([usernamePassword(
|
||||||
|
credentialsId: "${NODE_CREDENTIALS}",
|
||||||
|
usernameVariable: 'JENKINS_NODE_USERNAME',
|
||||||
|
passwordVariable: 'JENKINS_NODE_PASSWORD'
|
||||||
|
)]) {
|
||||||
|
sh '''
|
||||||
|
set -euo pipefail
|
||||||
|
if [ -d "$WORKSPACE/.ci" ]; then
|
||||||
|
printf '%s\n' "$JENKINS_NODE_PASSWORD" | \
|
||||||
|
sudo -S -p '' chown -R -- "$(id -u):$(id -g)" "$WORKSPACE/.ci"
|
||||||
|
fi
|
||||||
|
'''
|
||||||
|
}
|
||||||
deleteDir()
|
deleteDir()
|
||||||
checkout scm
|
checkout scm
|
||||||
}
|
}
|
||||||
@@ -375,6 +388,10 @@ pipeline {
|
|||||||
if [ -f "$DOCKER_CONFIG/config.json" ]; then
|
if [ -f "$DOCKER_CONFIG/config.json" ]; then
|
||||||
: >"$DOCKER_CONFIG/config.json"
|
: >"$DOCKER_CONFIG/config.json"
|
||||||
fi
|
fi
|
||||||
|
if [ -d "${CI_ROOT:-}" ]; then
|
||||||
|
printf '%s\n' "$JENKINS_NODE_PASSWORD" | \
|
||||||
|
sudo -S -p '' chown -R -- "$(id -u):$(id -g)" "$CI_ROOT" || true
|
||||||
|
fi
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
cleanWs(deleteDirs: true, notFailBuild: true)
|
cleanWs(deleteDirs: true, notFailBuild: true)
|
||||||
|
|||||||
Reference in New Issue
Block a user