Implement fully automated Jenkins HW8 setup with Ansible, JCasC and JJB
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
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
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user