From 2fca24be21093bbc7aa70e1e0e94f13d7392a2a9 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Fri, 20 Oct 2017 13:25:14 +0200 Subject: [PATCH] gitlab trigger: add support for different MR events also add tests for branch-filter-type on < 1.2.0 to make Zuul happy :( Change-Id: Ia0aa807e1139bacc3e808b6bdc9680648b596275 Signed-off-by: Evgeni Golov --- jenkins_jobs/modules/triggers.py | 7 +++++ tests/triggers/fixtures/gitlab001.xml | 2 ++ tests/triggers/fixtures/gitlab002.xml | 2 ++ tests/triggers/fixtures/gitlab003.xml | 2 ++ tests/triggers/fixtures/gitlab004.xml | 2 ++ tests/triggers/fixtures/gitlab005.xml | 2 ++ tests/triggers/fixtures/gitlab006.xml | 2 ++ .../fixtures/gitlab007.plugins_info.yaml | 3 +++ tests/triggers/fixtures/gitlab007.xml | 27 +++++++++++++++++++ tests/triggers/fixtures/gitlab007.yaml | 19 +++++++++++++ .../fixtures/gitlab008.plugins_info.yaml | 3 +++ tests/triggers/fixtures/gitlab008.xml | 27 +++++++++++++++++++ tests/triggers/fixtures/gitlab008.yaml | 11 ++++++++ 13 files changed, 109 insertions(+) create mode 100644 tests/triggers/fixtures/gitlab007.plugins_info.yaml create mode 100644 tests/triggers/fixtures/gitlab007.xml create mode 100644 tests/triggers/fixtures/gitlab007.yaml create mode 100644 tests/triggers/fixtures/gitlab008.plugins_info.yaml create mode 100644 tests/triggers/fixtures/gitlab008.xml create mode 100644 tests/triggers/fixtures/gitlab008.yaml diff --git a/jenkins_jobs/modules/triggers.py b/jenkins_jobs/modules/triggers.py index d5f3ba1d2..7d39d343f 100644 --- a/jenkins_jobs/modules/triggers.py +++ b/jenkins_jobs/modules/triggers.py @@ -1225,6 +1225,10 @@ def gitlab(registry, xml_parent, data): :arg bool trigger-push: Build on Push Events (default true) :arg bool trigger-merge-request: Build on Merge Request Events (default true) + :arg bool trigger-accepted-merge-request: Build on Accepted Merge Request + Events (>= 1.4.6) (default false) + :arg bool trigger-closed-merge-request: Build on Closed Merge Request + Events (>= 1.4.6) (default false) :arg str trigger-open-merge-request-push: Rebuild open Merge Requests on Push Events. @@ -1343,6 +1347,9 @@ def gitlab(registry, xml_parent, data): mapping = [ ('trigger-push', 'triggerOnPush', True), ('trigger-merge-request', 'triggerOnMergeRequest', True), + ('trigger-accepted-merge-request', 'triggerOnAcceptedMergeRequest', + False), + ('trigger-closed-merge-request', 'triggerOnClosedMergeRequest', False), ('trigger-note', 'triggerOnNoteRequest', True), ('note-regex', 'noteRegex', 'Jenkins please retry a build'), ('ci-skip', 'ciSkip', True), diff --git a/tests/triggers/fixtures/gitlab001.xml b/tests/triggers/fixtures/gitlab001.xml index 1c03682d4..012c4b9f2 100644 --- a/tests/triggers/fixtures/gitlab001.xml +++ b/tests/triggers/fixtures/gitlab001.xml @@ -7,6 +7,8 @@ true true + false + false true Jenkins please retry a build true diff --git a/tests/triggers/fixtures/gitlab002.xml b/tests/triggers/fixtures/gitlab002.xml index 48a583d9b..cf08f3ced 100644 --- a/tests/triggers/fixtures/gitlab002.xml +++ b/tests/triggers/fixtures/gitlab002.xml @@ -7,6 +7,8 @@ true true + false + false true Jenkins please retry a build true diff --git a/tests/triggers/fixtures/gitlab003.xml b/tests/triggers/fixtures/gitlab003.xml index baf204d09..609180d5c 100644 --- a/tests/triggers/fixtures/gitlab003.xml +++ b/tests/triggers/fixtures/gitlab003.xml @@ -7,6 +7,8 @@ true true + false + false true Jenkins please retry a build true diff --git a/tests/triggers/fixtures/gitlab004.xml b/tests/triggers/fixtures/gitlab004.xml index d10d661aa..5dcaeaa2f 100644 --- a/tests/triggers/fixtures/gitlab004.xml +++ b/tests/triggers/fixtures/gitlab004.xml @@ -7,6 +7,8 @@ false false + false + false true Jenkins please retry a build false diff --git a/tests/triggers/fixtures/gitlab005.xml b/tests/triggers/fixtures/gitlab005.xml index 3e1e168ce..2daa009bc 100644 --- a/tests/triggers/fixtures/gitlab005.xml +++ b/tests/triggers/fixtures/gitlab005.xml @@ -7,6 +7,8 @@ true true + false + false true Jenkins please retry a build true diff --git a/tests/triggers/fixtures/gitlab006.xml b/tests/triggers/fixtures/gitlab006.xml index af5fdac2d..c83293e41 100644 --- a/tests/triggers/fixtures/gitlab006.xml +++ b/tests/triggers/fixtures/gitlab006.xml @@ -7,6 +7,8 @@ false false + false + false true Retrigger false diff --git a/tests/triggers/fixtures/gitlab007.plugins_info.yaml b/tests/triggers/fixtures/gitlab007.plugins_info.yaml new file mode 100644 index 000000000..072da1d30 --- /dev/null +++ b/tests/triggers/fixtures/gitlab007.plugins_info.yaml @@ -0,0 +1,3 @@ +- longName: 'GitLab Plugin' + shortName: 'gitlab-plugin' + version: "1.4.6" diff --git a/tests/triggers/fixtures/gitlab007.xml b/tests/triggers/fixtures/gitlab007.xml new file mode 100644 index 000000000..f7611fd6e --- /dev/null +++ b/tests/triggers/fixtures/gitlab007.xml @@ -0,0 +1,27 @@ + + + + + never + All + + true + true + true + true + true + Jenkins please retry a build + true + true + true + true + true + false + true + true + + master, master2, local-test + broken-test, master-foo + + + diff --git a/tests/triggers/fixtures/gitlab007.yaml b/tests/triggers/fixtures/gitlab007.yaml new file mode 100644 index 000000000..ac2db3c49 --- /dev/null +++ b/tests/triggers/fixtures/gitlab007.yaml @@ -0,0 +1,19 @@ +triggers: + - gitlab: + trigger-push: true + trigger-merge-request: true + trigger-accepted-merge-request: true + trigger-closed-merge-request: true + ci-skip: true + set-build-description: true + add-note-merge-request: true + add-vote-merge-request: true + add-ci-message: true + allow-all-branches: true + include-branches: + - 'master' + - 'master2' + - 'local-test' + exclude-branches: + - 'broken-test' + - 'master-foo' diff --git a/tests/triggers/fixtures/gitlab008.plugins_info.yaml b/tests/triggers/fixtures/gitlab008.plugins_info.yaml new file mode 100644 index 000000000..56447ee98 --- /dev/null +++ b/tests/triggers/fixtures/gitlab008.plugins_info.yaml @@ -0,0 +1,3 @@ +- longName: 'GitLab Plugin' + shortName: 'gitlab-plugin' + version: "1.1.26" diff --git a/tests/triggers/fixtures/gitlab008.xml b/tests/triggers/fixtures/gitlab008.xml new file mode 100644 index 000000000..dcb2b4d3a --- /dev/null +++ b/tests/triggers/fixtures/gitlab008.xml @@ -0,0 +1,27 @@ + + + + + both + + + false + false + false + false + true + Jenkins please retry a build + false + true + false + false + false + false + true + false + + + + + + diff --git a/tests/triggers/fixtures/gitlab008.yaml b/tests/triggers/fixtures/gitlab008.yaml new file mode 100644 index 000000000..bad401fb1 --- /dev/null +++ b/tests/triggers/fixtures/gitlab008.yaml @@ -0,0 +1,11 @@ +triggers: + - gitlab: + trigger-push: false + trigger-merge-request: false + trigger-open-merge-request-push: both + ci-skip: false + set-build-description: false + add-note-merge-request: false + add-vote-merge-request: false + add-ci-message: true + branch-filter-type: All