Merge "Implement GitHub PR Comment Build Plugin"

This commit is contained in:
Zuul 2020-07-15 14:04:10 +00:00 committed by Gerrit Code Review
commit 156861a149
3 changed files with 74 additions and 1 deletions

View File

@ -1254,7 +1254,27 @@ def property_strategies(xml_parent, data):
max-survivability (optional)
Requires the :jenkins-plugins:`Pipeline Multibranch Plugin
<workflow-multibranch>`
* **trigger-build-on-pr-comment** (str): The comment body to
trigger a new build for a PR job when it is received. This
is compiled as a case insensitive regular expression, so
use ``".*"`` to trigger a build on any comment whatsoever.
(optional)
Requires the :jenkins-plugins:`GitHub PR Comment Build Plugin
<github-pr-comment-build>`
* **trigger-build-on-pr-review** (bool): This property will
cause a job for a pull request ``(PR-*)`` to be triggered
immediately when a review is made on the PR in GitHub.
This has no effect on jobs that are not for pull requests.
(optional)
Requires the :jenkins-plugins:`GitHub PR Comment Build Plugin
<github-pr-comment-build>`
* **trigger-build-on-pr-update** (bool): This property will
cause a job for a pull request ``(PR-*)`` to be triggered
immediately when the PR title or description is edited in
GitHub. This has no effect on jobs that are not for pull
requests. (optional)
Requires the :jenkins-plugins:`GitHub PR Comment Build Plugin
<github-pr-comment-build>`
* **named-branches** (dict): Named branches get different properties.
Comprised of a list of defaults and a list of property strategy
exceptions for use with specific branches.
@ -1271,6 +1291,27 @@ def property_strategies(xml_parent, data):
max-survivability (optional)
Requires the :jenkins-plugins:`Pipeline Multibranch Plugin
<workflow-multibranch>`
* **trigger-build-on-pr-comment** (str): The comment body to
trigger a new build for a PR job when it is received. This
is compiled as a case insensitive regular expression, so
use ``".*"`` to trigger a build on any comment whatsoever.
(optional)
Requires the :jenkins-plugins:`GitHub PR Comment Build Plugin
<github-pr-comment-build>`
* **trigger-build-on-pr-review** (bool): This property will
cause a job for a pull request ``(PR-*)`` to be triggered
immediately when a review is made on the PR in GitHub.
This has no effect on jobs that are not for pull requests.
(optional)
Requires the :jenkins-plugins:`GitHub PR Comment Build Plugin
<github-pr-comment-build>`
* **trigger-build-on-pr-update** (bool): This property will
cause a job for a pull request ``(PR-*)`` to be triggered
immediately when the PR title or description is edited in
GitHub. This has no effect on jobs that are not for pull
requests. (optional)
Requires the :jenkins-plugins:`GitHub PR Comment Build Plugin
<github-pr-comment-build>`
* **exceptions** (list): A list of branch names and the property
strategies to be used on that branch, instead of any listed
@ -1436,6 +1477,7 @@ def apply_property_strategies(props_elem, props_list):
basic_property_strategies = "jenkins.branch"
workflow_multibranch = "org.jenkinsci.plugins.workflow.multibranch"
pr_comment_build = "com.adobe.jenkins.github__pr__comment__build"
# Valid options for the pipeline branch durability override.
pbdo_map = collections.OrderedDict(
[
@ -1445,6 +1487,13 @@ def apply_property_strategies(props_elem, props_list):
]
)
pcb_bool_opts = collections.OrderedDict(
[
("trigger-build-on-pr-review", ".TriggerPRReviewBranchProperty"),
("trigger-build-on-pr-update", ".TriggerPRUpdateBranchProperty"),
]
)
for dbs_list in props_list:
if dbs_list.get("suppress-scm-triggering", False):
@ -1465,3 +1514,19 @@ def apply_property_strategies(props_elem, props_list):
{"plugin": "workflow-multibranch"},
)
XML.SubElement(pbdo_elem, "hint").text = pbdo_map.get(pbdo_val)
tbopc_val = dbs_list.get("trigger-build-on-pr-comment", None)
if tbopc_val:
tbopc_elem = XML.SubElement(
props_elem,
"".join([pr_comment_build, ".TriggerPRCommentBranchProperty"]),
{"plugin": "github-pr-comment-build"},
)
XML.SubElement(tbopc_elem, "commentBody").text = tbopc_val
for opt in pcb_bool_opts:
if dbs_list.get(opt, False):
XML.SubElement(
props_elem,
"".join([pr_comment_build, pcb_bool_opts.get(opt)]),
{"plugin": "github-pr-comment-build"},
)

View File

@ -107,6 +107,11 @@
<org.jenkinsci.plugins.workflow.multibranch.DurabilityHintBranchProperty plugin="workflow-multibranch">
<hint>MAX_SURVIVABILITY</hint>
</org.jenkinsci.plugins.workflow.multibranch.DurabilityHintBranchProperty>
<com.adobe.jenkins.github__pr__comment__build.TriggerPRCommentBranchProperty plugin="github-pr-comment-build">
<commentBody>Ci build!</commentBody>
</com.adobe.jenkins.github__pr__comment__build.TriggerPRCommentBranchProperty>
<com.adobe.jenkins.github__pr__comment__build.TriggerPRReviewBranchProperty plugin="github-pr-comment-build"/>
<com.adobe.jenkins.github__pr__comment__build.TriggerPRUpdateBranchProperty plugin="github-pr-comment-build"/>
</a>
</properties>
</strategy>

View File

@ -20,6 +20,9 @@ scm:
all-branches:
- suppress-scm-triggering: true
- pipeline-branch-durability-override: max-survivability
- trigger-build-on-pr-comment: "Ci build!"
- trigger-build-on-pr-review: true
- trigger-build-on-pr-update: true
build-strategies:
- tags:
ignore-tags-newer-than: 1