diff --git a/jobs/swh-mirror.yaml b/jobs/swh-mirror.yaml --- a/jobs/swh-mirror.yaml +++ b/jobs/swh-mirror.yaml @@ -4,8 +4,9 @@ jobs: - "{name}" - "{name}/run-tests" + - "{name}/gitlab-run-tests" -- job-template: +- job-template: &swh_mirror_run_tests name: "{name}/run-tests" project-type: pipeline docker_image: tox @@ -15,3 +16,19 @@ - timed: "0 4 * * *" dsl: !include-jinja2: templates/swh-mirror-run-tests.groovy.j2 + +- job-template: + name: "{name}/gitlab-run-tests" + gitlab_project: true + properties: + - gitlab: + connection: "{gitlab_connection_name}" + triggers: + - gitlab: + trigger-push: true + trigger-merge-request: true + add-ci-message: true + cancel-pending-builds-on-update: true + # secret jenkins token is generated when executing tox + secret-token: !include-raw: jobs/templates/jenkins-token + <<: *swh_mirror_run_tests diff --git a/jobs/templates/swh-mirror-run-tests.groovy.j2 b/jobs/templates/swh-mirror-run-tests.groovy.j2 --- a/jobs/templates/swh-mirror-run-tests.groovy.j2 +++ b/jobs/templates/swh-mirror-run-tests.groovy.j2 @@ -21,7 +21,14 @@ } steps { + {%- if gitlab_project %} + updateGitlabCommitStatus name: 'jenkins', state: 'running' + {%- endif %} + {%- if not gitlab_project %} git url: "https://forge.softwareheritage.org/source/swh-mirror.git" + {%- else %} + git url: "{{gitlab_url}}/swh/infra/swh-mirror.git" + {%- endif %} } } @@ -83,5 +90,16 @@ ''' } } + {%- if gitlab_project %} + failure { + updateGitlabCommitStatus name: 'jenkins', state: 'failed' + } + success { + updateGitlabCommitStatus name: 'jenkins', state: 'success' + } + aborted { + updateGitlabCommitStatus name: 'jenkins', state: 'canceled' + } + {%- endif %} } } diff --git a/jobs/tools/setup-gitlab-webhooks.groovy.j2 b/jobs/tools/setup-gitlab-webhooks.groovy.j2 --- a/jobs/tools/setup-gitlab-webhooks.groovy.j2 +++ b/jobs/tools/setup-gitlab-webhooks.groovy.j2 @@ -30,6 +30,8 @@ true, true, false) setupGitlabWebhook("swh/devel/swh-docs", "DDOC/gitlab-builds", true, true, false) + setupGitlabWebhook("swh/infra/swh-mirror", "DFP/gitlab-run-tests", + true, true, false) projects = readYaml(file: 'jobs/swh-packages.yaml') for (project in projects) {