blob: 5815cd3a7a46e97b12a6b150f8119bade3b317c6 [file] [log] [blame]
node('sre-team-infra') {
timestamps() {
ansiColor('xterm') {
tmp_jenkins_config = '/dev/shm/sre-jenkins-job-builder.ini'
stage('Checkout') {
checkout scm
}
stage('Prepre venv'){
sh """
if [ ! -d .venv ]; then
echo "Can't find python virtal env, installing"
virtualenv -p python3 .venv
fi
if [ -z "\$(./.venv/bin/pip freeze | grep jenkins-job-builder)" ]; then
./.venv/bin/pip install 'jenkins-job-builder>=2.0.0.0b2'
fi
"""
}
stage('Prepre config'){
withCredentials([usernamePassword(credentialsId: 'jenkins-job-builder',
passwordVariable: 'jpass', usernameVariable: 'juser')]) {
sh """
cp jobs/config/sre-jenkins-job-builder-example.ini ${tmp_jenkins_config}
sed -i "s/user=some_user/user=\${juser}/g" ${tmp_jenkins_config}
sed -i "s/password=some_password/password=\${jpass}/g" ${tmp_jenkins_config}
"""
}
}
stage('Deploy jobs'){
sh """
cd jobs
../.venv/bin/jenkins-jobs --conf ${tmp_jenkins_config} update ./
rm ${tmp_jenkins_config}
"""
}
}
}
}