From 6033c80457672264a24a9226c2cf18ebe0bbdad3 Mon Sep 17 00:00:00 2001 From: Barnaby Court Date: Wed, 18 Feb 2015 11:10:36 -0500 Subject: [PATCH] Enable whitelisted-orgs-as-admins for ghprb trigger Adds support for having all members of a whitelisted organization automatically have admin rights for the github pull request builder trigger. Details on this functionality can be found at https://wiki.jenkins-ci.org/display/JENKINS/ GitHub+pull+request+builder+plugin Change-Id: Ieca5a789a79d1ad91783fcd4608d26a8d6d61878 --- jenkins_jobs/modules/triggers.py | 4 ++++ tests/triggers/fixtures/github-pull-request.xml | 1 + tests/triggers/fixtures/github-pull-request.yaml | 1 + 3 files changed, 6 insertions(+) diff --git a/jenkins_jobs/modules/triggers.py b/jenkins_jobs/modules/triggers.py index 6aa769769..9e1e8e122 100644 --- a/jenkins_jobs/modules/triggers.py +++ b/jenkins_jobs/modules/triggers.py @@ -670,6 +670,8 @@ def github_pull_request(parser, xml_parent, data): :arg list admin-list: the users with admin rights (optional) :arg list white-list: users whose pull requests build (optional) :arg list org-list: orgs whose users should be white listed (optional) + :arg bool allow-whitelist-orgs-as-admins: members of white listed orgs + will have admin rights. (default false) :arg string cron: cron syntax of when to run (optional) :arg string trigger-phrase: when filled, commenting this phrase in the pull request will trigger a build (optional) @@ -695,6 +697,8 @@ def github_pull_request(parser, xml_parent, data): XML.SubElement(ghprb, 'spec').text = data.get('cron', '') admin_string = "\n".join(data.get('admin-list', [])) XML.SubElement(ghprb, 'adminlist').text = admin_string + XML.SubElement(ghprb, 'allowMembersOfWhitelistedOrgsAsAdmin').text = str( + data.get('allow-whitelist-orgs-as-admins', False)).lower() white_string = "\n".join(data.get('white-list', [])) XML.SubElement(ghprb, 'whitelist').text = white_string org_string = "\n".join(data.get('org-list', [])) diff --git a/tests/triggers/fixtures/github-pull-request.xml b/tests/triggers/fixtures/github-pull-request.xml index 7d00e165d..188f75412 100644 --- a/tests/triggers/fixtures/github-pull-request.xml +++ b/tests/triggers/fixtures/github-pull-request.xml @@ -5,6 +5,7 @@ * * * * * user1 user2 + true user3 user4 org1 diff --git a/tests/triggers/fixtures/github-pull-request.yaml b/tests/triggers/fixtures/github-pull-request.yaml index 36a228e8a..5e8100ead 100644 --- a/tests/triggers/fixtures/github-pull-request.yaml +++ b/tests/triggers/fixtures/github-pull-request.yaml @@ -15,6 +15,7 @@ triggers: github-hooks: true permit-all: false auto-close-on-fail: false + allow-whitelist-orgs-as-admins: true white-list-target-branches: - master - testing