From 5c7a4e4d5c89aca57987d2304f603dd7520e4d47 Mon Sep 17 00:00:00 2001 From: Russell Sim Date: Sat, 20 May 2017 22:48:21 +0200 Subject: [PATCH] Add new fields to Github pull request builder plugin - Adds black/white label lists - Adds skip build phrase Change-Id: I962ec17a32317cb6757ef3b208bd68dc24a0afb7 --- jenkins_jobs/modules/triggers.py | 13 +++++++++++++ .../fixtures/github-pull-request-comments.xml | 3 +++ .../github-pull-request-multiple-extensions.xml | 3 +++ .../fixtures/github-pull-request-status.xml | 3 +++ tests/triggers/fixtures/github-pull-request.xml | 5 +++++ tests/triggers/fixtures/github-pull-request.yaml | 7 +++++++ 6 files changed, 34 insertions(+) diff --git a/jenkins_jobs/modules/triggers.py b/jenkins_jobs/modules/triggers.py index d130e0154..71faaea49 100644 --- a/jenkins_jobs/modules/triggers.py +++ b/jenkins_jobs/modules/triggers.py @@ -902,6 +902,12 @@ def github_pull_request(registry, xml_parent, data): in the pull request will trigger a build (optional) :arg bool only-trigger-phrase: only commenting the trigger phrase in the pull request will trigger a build (default false) + :arg string skip-build-phrase: when filled, adding this phrase to + the pull request title or body will not trigger a build (optional) + :arg string black-list-labels: list of GitHub labels for which the build + should not be triggered (optional) + :arg string white-list-labels: list of GitHub labels for which the build + should only be triggered. (Leave blank for 'any') (optional) :arg bool github-hooks: use github hook (default false) :arg bool permit-all: build every pull request automatically without asking (default false) @@ -941,6 +947,7 @@ def github_pull_request(registry, xml_parent, data): Example: .. literalinclude:: /../../tests/triggers/fixtures/github-pull-request.yaml + """ ghprb = XML.SubElement(xml_parent, 'org.jenkinsci.plugins.ghprb.' 'GhprbTrigger') @@ -953,6 +960,10 @@ def github_pull_request(registry, xml_parent, data): XML.SubElement(ghprb, 'whitelist').text = white_string org_string = "\n".join(data.get('org-list', [])) XML.SubElement(ghprb, 'orgslist').text = org_string + white_list_labels_string = "\n".join(data.get('white-list-labels', [])) + XML.SubElement(ghprb, 'whiteListLabels').text = white_list_labels_string + black_list_labels_string = "\n".join(data.get('black-list-labels', [])) + XML.SubElement(ghprb, 'blackListLabels').text = black_list_labels_string XML.SubElement(ghprb, 'cron').text = data.get('cron', '') build_desc_template = data.get('build-desc-template', '') @@ -962,6 +973,8 @@ def github_pull_request(registry, xml_parent, data): XML.SubElement(ghprb, 'triggerPhrase').text = \ data.get('trigger-phrase', '') + XML.SubElement(ghprb, 'skipBuildPhrase').text = str( + data.get('skip-build-phrase', '')).lower() XML.SubElement(ghprb, 'onlyTriggerPhrase').text = str( data.get('only-trigger-phrase', False)).lower() XML.SubElement(ghprb, 'useGitHubHooks').text = str( diff --git a/tests/triggers/fixtures/github-pull-request-comments.xml b/tests/triggers/fixtures/github-pull-request-comments.xml index b757034ac..6c511897d 100644 --- a/tests/triggers/fixtures/github-pull-request-comments.xml +++ b/tests/triggers/fixtures/github-pull-request-comments.xml @@ -10,8 +10,11 @@ user2 user4 org1 org2 + + * * * * * retest this please + true true false diff --git a/tests/triggers/fixtures/github-pull-request-multiple-extensions.xml b/tests/triggers/fixtures/github-pull-request-multiple-extensions.xml index 6570bc5c1..fc7341eec 100644 --- a/tests/triggers/fixtures/github-pull-request-multiple-extensions.xml +++ b/tests/triggers/fixtures/github-pull-request-multiple-extensions.xml @@ -10,8 +10,11 @@ user2 user4 org1 org2 + + * * * * * retest this please + true true false diff --git a/tests/triggers/fixtures/github-pull-request-status.xml b/tests/triggers/fixtures/github-pull-request-status.xml index 20e1fbe92..a188838a0 100644 --- a/tests/triggers/fixtures/github-pull-request-status.xml +++ b/tests/triggers/fixtures/github-pull-request-status.xml @@ -10,8 +10,11 @@ user2 user4 org1 org2 + + * * * * * retest this please + true true false diff --git a/tests/triggers/fixtures/github-pull-request.xml b/tests/triggers/fixtures/github-pull-request.xml index 441f26052..c1222320e 100644 --- a/tests/triggers/fixtures/github-pull-request.xml +++ b/tests/triggers/fixtures/github-pull-request.xml @@ -10,9 +10,14 @@ user2 user4 org1 org2 + label1 +label2 + label3 +label4 * * * * * build description retest this please + no tests true true false diff --git a/tests/triggers/fixtures/github-pull-request.yaml b/tests/triggers/fixtures/github-pull-request.yaml index 8307392e0..58de03dcf 100644 --- a/tests/triggers/fixtures/github-pull-request.yaml +++ b/tests/triggers/fixtures/github-pull-request.yaml @@ -9,9 +9,16 @@ triggers: org-list: - org1 - org2 + white-list-labels: + - label1 + - label2 + black-list-labels: + - label3 + - label4 cron: '* * * * *' build-desc-template: "build description" trigger-phrase: 'retest this please' + skip-build-phrase: 'no tests' only-trigger-phrase: true github-hooks: true permit-all: false