blob: 5815cd3a7a46e97b12a6b150f8119bade3b317c6 [file] [log] [blame]
Sergey Galkin24ebd762020-01-14 14:36:34 +04001node('sre-team-infra') {
2 timestamps() {
3 ansiColor('xterm') {
4 tmp_jenkins_config = '/dev/shm/sre-jenkins-job-builder.ini'
5 stage('Checkout') {
6 checkout scm
7 }
8 stage('Prepre venv'){
9 sh """
10 if [ ! -d .venv ]; then
11 echo "Can't find python virtal env, installing"
12 virtualenv -p python3 .venv
13 fi
14 if [ -z "\$(./.venv/bin/pip freeze | grep jenkins-job-builder)" ]; then
15 ./.venv/bin/pip install 'jenkins-job-builder>=2.0.0.0b2'
16 fi
17 """
18 }
19 stage('Prepre config'){
20 withCredentials([usernamePassword(credentialsId: 'jenkins-job-builder',
21 passwordVariable: 'jpass', usernameVariable: 'juser')]) {
22 sh """
23 cp jobs/config/sre-jenkins-job-builder-example.ini ${tmp_jenkins_config}
24 sed -i "s/user=some_user/user=\${juser}/g" ${tmp_jenkins_config}
25 sed -i "s/password=some_password/password=\${jpass}/g" ${tmp_jenkins_config}
26 """
27 }
28 }
29 stage('Deploy jobs'){
30 sh """
31 cd jobs
32 ../.venv/bin/jenkins-jobs --conf ${tmp_jenkins_config} update ./
33 rm ${tmp_jenkins_config}
34 """
35 }
36 }
37 }
38}