Add new fields to Github pull request builder plugin

- Adds black/white label lists
- Adds skip build phrase

Change-Id: I962ec17a32317cb6757ef3b208bd68dc24a0afb7
This commit is contained in:
Russell Sim 2017-05-20 22:48:21 +02:00
parent e7346dedd8
commit 5c7a4e4d5c
6 changed files with 34 additions and 0 deletions

View File

@ -902,6 +902,12 @@ def github_pull_request(registry, xml_parent, data):
in the pull request will trigger a build (optional) in the pull request will trigger a build (optional)
:arg bool only-trigger-phrase: only commenting the trigger phrase :arg bool only-trigger-phrase: only commenting the trigger phrase
in the pull request will trigger a build (default false) 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 github-hooks: use github hook (default false)
:arg bool permit-all: build every pull request automatically :arg bool permit-all: build every pull request automatically
without asking (default false) without asking (default false)
@ -941,6 +947,7 @@ def github_pull_request(registry, xml_parent, data):
Example: Example:
.. literalinclude:: /../../tests/triggers/fixtures/github-pull-request.yaml .. literalinclude:: /../../tests/triggers/fixtures/github-pull-request.yaml
""" """
ghprb = XML.SubElement(xml_parent, 'org.jenkinsci.plugins.ghprb.' ghprb = XML.SubElement(xml_parent, 'org.jenkinsci.plugins.ghprb.'
'GhprbTrigger') 'GhprbTrigger')
@ -953,6 +960,10 @@ def github_pull_request(registry, xml_parent, data):
XML.SubElement(ghprb, 'whitelist').text = white_string XML.SubElement(ghprb, 'whitelist').text = white_string
org_string = "\n".join(data.get('org-list', [])) org_string = "\n".join(data.get('org-list', []))
XML.SubElement(ghprb, 'orgslist').text = org_string 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', '') XML.SubElement(ghprb, 'cron').text = data.get('cron', '')
build_desc_template = data.get('build-desc-template', '') 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 = \ XML.SubElement(ghprb, 'triggerPhrase').text = \
data.get('trigger-phrase', '') data.get('trigger-phrase', '')
XML.SubElement(ghprb, 'skipBuildPhrase').text = str(
data.get('skip-build-phrase', '')).lower()
XML.SubElement(ghprb, 'onlyTriggerPhrase').text = str( XML.SubElement(ghprb, 'onlyTriggerPhrase').text = str(
data.get('only-trigger-phrase', False)).lower() data.get('only-trigger-phrase', False)).lower()
XML.SubElement(ghprb, 'useGitHubHooks').text = str( XML.SubElement(ghprb, 'useGitHubHooks').text = str(

View File

@ -10,8 +10,11 @@ user2</adminlist>
user4</whitelist> user4</whitelist>
<orgslist>org1 <orgslist>org1
org2</orgslist> org2</orgslist>
<whiteListLabels/>
<blackListLabels/>
<cron>* * * * *</cron> <cron>* * * * *</cron>
<triggerPhrase>retest this please</triggerPhrase> <triggerPhrase>retest this please</triggerPhrase>
<skipBuildPhrase/>
<onlyTriggerPhrase>true</onlyTriggerPhrase> <onlyTriggerPhrase>true</onlyTriggerPhrase>
<useGitHubHooks>true</useGitHubHooks> <useGitHubHooks>true</useGitHubHooks>
<permitAll>false</permitAll> <permitAll>false</permitAll>

View File

@ -10,8 +10,11 @@ user2</adminlist>
user4</whitelist> user4</whitelist>
<orgslist>org1 <orgslist>org1
org2</orgslist> org2</orgslist>
<whiteListLabels/>
<blackListLabels/>
<cron>* * * * *</cron> <cron>* * * * *</cron>
<triggerPhrase>retest this please</triggerPhrase> <triggerPhrase>retest this please</triggerPhrase>
<skipBuildPhrase/>
<onlyTriggerPhrase>true</onlyTriggerPhrase> <onlyTriggerPhrase>true</onlyTriggerPhrase>
<useGitHubHooks>true</useGitHubHooks> <useGitHubHooks>true</useGitHubHooks>
<permitAll>false</permitAll> <permitAll>false</permitAll>

View File

@ -10,8 +10,11 @@ user2</adminlist>
user4</whitelist> user4</whitelist>
<orgslist>org1 <orgslist>org1
org2</orgslist> org2</orgslist>
<whiteListLabels/>
<blackListLabels/>
<cron>* * * * *</cron> <cron>* * * * *</cron>
<triggerPhrase>retest this please</triggerPhrase> <triggerPhrase>retest this please</triggerPhrase>
<skipBuildPhrase/>
<onlyTriggerPhrase>true</onlyTriggerPhrase> <onlyTriggerPhrase>true</onlyTriggerPhrase>
<useGitHubHooks>true</useGitHubHooks> <useGitHubHooks>true</useGitHubHooks>
<permitAll>false</permitAll> <permitAll>false</permitAll>

View File

@ -10,9 +10,14 @@ user2</adminlist>
user4</whitelist> user4</whitelist>
<orgslist>org1 <orgslist>org1
org2</orgslist> org2</orgslist>
<whiteListLabels>label1
label2</whiteListLabels>
<blackListLabels>label3
label4</blackListLabels>
<cron>* * * * *</cron> <cron>* * * * *</cron>
<buildDescTemplate>build description</buildDescTemplate> <buildDescTemplate>build description</buildDescTemplate>
<triggerPhrase>retest this please</triggerPhrase> <triggerPhrase>retest this please</triggerPhrase>
<skipBuildPhrase>no tests</skipBuildPhrase>
<onlyTriggerPhrase>true</onlyTriggerPhrase> <onlyTriggerPhrase>true</onlyTriggerPhrase>
<useGitHubHooks>true</useGitHubHooks> <useGitHubHooks>true</useGitHubHooks>
<permitAll>false</permitAll> <permitAll>false</permitAll>

View File

@ -9,9 +9,16 @@ triggers:
org-list: org-list:
- org1 - org1
- org2 - org2
white-list-labels:
- label1
- label2
black-list-labels:
- label3
- label4
cron: '* * * * *' cron: '* * * * *'
build-desc-template: "build description" build-desc-template: "build description"
trigger-phrase: 'retest this please' trigger-phrase: 'retest this please'
skip-build-phrase: 'no tests'
only-trigger-phrase: true only-trigger-phrase: true
github-hooks: true github-hooks: true
permit-all: false permit-all: false