diff --git a/jobs/tools/jenkins-jobs-builder.yaml b/jobs/tools/jenkins-jobs-builder.yaml new file mode 100644 index 0000000..d401a34 --- /dev/null +++ b/jobs/tools/jenkins-jobs-builder.yaml @@ -0,0 +1,58 @@ +- job: + name: jenkins-tools/swh-jenkins-jobs-builder + project-type: pipeline + description: Update jenkins jobs + node: built-in + auth-token: "ph4br1cat0r" + + properties: + - build-discarder: + days-to-keep: 7 + + dsl: | + pipeline { + agent any + + stages { + + stage('Checkout Repository') { + steps { + checkout([ + $class: 'GitSCM', + branches: [[name: 'gitlab-integration']], + userRemoteConfigs: [[ + url: "file:///opt/swh-jenkins-jobs", + ]], + ]) + } + } + + stage('Update Jenkins jobs') { + steps { + sh('tox -- update --delete-old') + } + } + + stage('Setup jenkins integration on gitlab') { + steps { + script { + projects = readYaml(file: 'jobs/swh-packages.yaml') + for (project in projects) { + if (project.containsKey("project")) { + def jenkinsFolder = project.get('project').get('name') + def repoName= project.get('project').get('repo_name') + build( + job: '/jenkins-tools/gitlab-jenkins-integration', + parameters: [ + string(name: 'jenkins_job_name', value: "${jenkinsFolder}/gitlab-tests"), + string(name: 'gitlab_project', value: "swh/devel/${repoName}"), + ], + wait: false, + ) + } + } + } + } + } + } + }