From 066804db17710277d6cfcb25d38cfd9c7cca038b Mon Sep 17 00:00:00 2001 From: David Caro Date: Wed, 27 Jan 2016 18:33:54 +0100 Subject: [PATCH] Added github-pull-request-merge publisher Change-Id: I00dc6d90640aa1771fe3387f30f40e0355290379 Signed-off-by: David Caro --- jenkins_jobs/modules/publishers.py | 46 +++++++++++++++++++ .../fixtures/github-pull-request-merge001.xml | 12 +++++ .../github-pull-request-merge001.yaml | 7 +++ .../fixtures/github-pull-request-merge002.xml | 11 +++++ .../github-pull-request-merge002.yaml | 2 + 5 files changed, 78 insertions(+) create mode 100644 tests/publishers/fixtures/github-pull-request-merge001.xml create mode 100644 tests/publishers/fixtures/github-pull-request-merge001.yaml create mode 100644 tests/publishers/fixtures/github-pull-request-merge002.xml create mode 100644 tests/publishers/fixtures/github-pull-request-merge002.yaml diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index 0b703d7fd..c8855e48b 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -5793,6 +5793,52 @@ def openshift_deploy_canceller(parser, xml_parent, data): convert_mapping_to_xml(osb, data, mapping) +def github_pull_request_merge(parser, xml_parent, data): + """yaml: github-pull-request-merge + This action merges the pull request that triggered the build (see the + github pull request trigger) + Requires the Jenkins :jenkins-wiki:`GitHub pull request builder plugin + + + + :arg bool only-admins-merge: if `true` only administrators can merge the + pull request, (default false) + :arg bool disallow-own-code: if `true` will allow merging your own pull + requests, in opposite to needing someone else to trigger the merge. + (default false) + :arg bool merge-comment: Comment to set on the merge commit (optional) + :arg bool fail-on-non-merge: fail the job if the merge was unsuccessful + (default false) + :arg bool delete-on-merge: Delete the branch of the pull request on + successful merge (default false) + + Full Example: + + .. literalinclude:: + ../../tests/publishers/fixtures/github-pull-request-merge001.yaml + :language: yaml + + Minimal Example: + + .. literalinclude:: + ../../tests/publishers/fixtures/github-pull-request-merge002.yaml + :language: yaml + """ + + osb = XML.SubElement(xml_parent, + 'org.jenkinsci.plugins.ghprb.GhprbPullRequestMerge') + mapping = [ + # option, xml name, default value + ("only-admins-merge", 'onlyAdminsMerge', 'false'), + ("disallow-own-code", 'disallowOwnCode', 'false'), + ("merge-comment", 'mergeComment', None), + ("fail-on-non-merge", 'failOnNonMerge', 'false'), + ("delete-on-merge", 'deleteOnMerge', 'false'), + ] + + convert_mapping_to_xml(osb, data, mapping) + + class Publishers(jenkins_jobs.modules.base.Base): sequence = 70 diff --git a/tests/publishers/fixtures/github-pull-request-merge001.xml b/tests/publishers/fixtures/github-pull-request-merge001.xml new file mode 100644 index 000000000..86ac58d2b --- /dev/null +++ b/tests/publishers/fixtures/github-pull-request-merge001.xml @@ -0,0 +1,12 @@ + + + + + true + true + my fancy commit message + true + true + + + diff --git a/tests/publishers/fixtures/github-pull-request-merge001.yaml b/tests/publishers/fixtures/github-pull-request-merge001.yaml new file mode 100644 index 000000000..725258466 --- /dev/null +++ b/tests/publishers/fixtures/github-pull-request-merge001.yaml @@ -0,0 +1,7 @@ +publishers: + - github-pull-request-merge: + only-admins-merge: true + disallow-own-code: true + merge-comment: 'my fancy commit message' + fail-on-non-merge: true + delete-on-merge: true diff --git a/tests/publishers/fixtures/github-pull-request-merge002.xml b/tests/publishers/fixtures/github-pull-request-merge002.xml new file mode 100644 index 000000000..408f02334 --- /dev/null +++ b/tests/publishers/fixtures/github-pull-request-merge002.xml @@ -0,0 +1,11 @@ + + + + + false + false + false + false + + + diff --git a/tests/publishers/fixtures/github-pull-request-merge002.yaml b/tests/publishers/fixtures/github-pull-request-merge002.yaml new file mode 100644 index 000000000..2cbdc7d68 --- /dev/null +++ b/tests/publishers/fixtures/github-pull-request-merge002.yaml @@ -0,0 +1,2 @@ +publishers: + - github-pull-request-merge