Files
pw/config/jobs/scripts/jobs-uploader.groovy
T

45 lines
931 B
Groovy

pipeline {
agent { label 'jjb' }
options {
timestamps()
ansiColor('xterm')
}
stages {
stage('Validate Input') {
steps {
sh '''
set -eux
test -d "${JJB_PATH}"
test -f "${JJB_PATH}/global.yaml"
'''
}
}
stage('Deploy Jobs') {
steps {
withCredentials([usernamePassword(
credentialsId: 'jenkins-admin-userpass',
usernameVariable: 'J_USER',
passwordVariable: 'J_PASS'
)]) {
sh '''
set -eux
cat > /tmp/jenkins-job-builder.ini <<EOF
[job_builder]
ignore_cache=True
keep_descriptions=True
recursive=True
[jenkins]
url=${JENKINS_URL_INTERNAL}
user=${J_USER}
password=${J_PASS}
EOF
jenkins-jobs --conf /tmp/jenkins-job-builder.ini --flush-cache update "${JJB_PATH}"
rm -f /tmp/jenkins-job-builder.ini
'''
}
}
}
}
}