Add support for build trigger using PR label.
Story: https://storyboard.openstack.org/#!/story/2011138 The feature is supported by GitHub PR Comment Build Plugin. The change extends property strategy configuration with a label regex parameter that triggers a job. The job configuration is only supported by trusted users that have write access to the repository. Change-Id: Ib6910c6ebb78801710e334503a4545f08498ed0b
This commit is contained in:
parent
60f0316389
commit
2a907c9ab0
@ -1492,6 +1492,12 @@ def property_strategies(xml_parent, data):
|
|||||||
is a collaborator of the GitHub project.
|
is a collaborator of the GitHub project.
|
||||||
Requires the :jenkins-plugins:`GitHub PR Comment Build Plugin
|
Requires the :jenkins-plugins:`GitHub PR Comment Build Plugin
|
||||||
<github-pr-comment-build>`
|
<github-pr-comment-build>`
|
||||||
|
* **trigger-build-on-pr-label** (str or dict): PR label to trigger
|
||||||
|
a new build for a PR job when it is applied to the PR.
|
||||||
|
If dictionary syntax is used, the option requires 1 field:
|
||||||
|
``label-regex`` with the label regular expression.
|
||||||
|
Requires the :jenkins-plugins:`GitHub PR Comment Build Plugin
|
||||||
|
<github-pr-comment-build>`
|
||||||
* **trigger-build-on-pr-review** (bool or dict): This property will
|
* **trigger-build-on-pr-review** (bool or dict): This property will
|
||||||
cause a job for a pull request ``(PR-*)`` to be triggered
|
cause a job for a pull request ``(PR-*)`` to be triggered
|
||||||
immediately when a review is made on the PR in GitHub.
|
immediately when a review is made on the PR in GitHub.
|
||||||
@ -1856,6 +1862,38 @@ def apply_property_strategies(props_elem, props_list):
|
|||||||
pos=dbs_list.value_pos.get(attr),
|
pos=dbs_list.value_pos.get(attr),
|
||||||
ctx=ctx,
|
ctx=ctx,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
tbopl_val = dbs_list.get("trigger-build-on-pr-label", None)
|
||||||
|
if tbopl_val:
|
||||||
|
tbopl_elem = XML.SubElement(
|
||||||
|
props_elem,
|
||||||
|
"".join([pr_comment_build, ".TriggerPRLabelBranchProperty"]),
|
||||||
|
{"plugin": "github-pr-comment-build"},
|
||||||
|
)
|
||||||
|
if isinstance(tbopl_val, dict):
|
||||||
|
if "label-regex" not in tbopl_val:
|
||||||
|
raise MissingAttributeError(
|
||||||
|
"trigger-build-on-pr-label[label-regex]",
|
||||||
|
pos=dbs_list.key_pos.get("trigger-build-on-pr-label"),
|
||||||
|
)
|
||||||
|
|
||||||
|
XML.SubElement(tbopl_elem, "label").text = tbopl_val["label-regex"]
|
||||||
|
elif isinstance(tbopl_val, str):
|
||||||
|
XML.SubElement(tbopl_elem, "label").text = str(tbopl_val)
|
||||||
|
else:
|
||||||
|
attr = "trigger-build-on-pr-label"
|
||||||
|
ctx = [Context(f"For attribute {attr!r}", dbs_list.key_pos.get(attr))]
|
||||||
|
raise InvalidAttributeError(
|
||||||
|
attr,
|
||||||
|
tbopl_val,
|
||||||
|
pos=dbs_list.value_pos.get(attr),
|
||||||
|
ctx=ctx,
|
||||||
|
)
|
||||||
|
|
||||||
|
# currently the only permissions available is WRITE and untrusted users are not allowed
|
||||||
|
XML.SubElement(tbopl_elem, "allowUntrusted").text = "false"
|
||||||
|
XML.SubElement(tbopl_elem, "minimumPermissions").text = "WRITE"
|
||||||
|
|
||||||
for opt in pcb_bool_opts:
|
for opt in pcb_bool_opts:
|
||||||
opt_value = dbs_list.get(opt, None)
|
opt_value = dbs_list.get(opt, None)
|
||||||
if opt_value:
|
if opt_value:
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
scm_github_comment_plugin_invalid_type005.yaml:18:19: For attribute 'trigger-build-on-pr-label'
|
||||||
|
- trigger-build-on-pr-label:
|
||||||
|
^
|
||||||
|
scm_github_comment_plugin_invalid_type005.yaml:19:21: '['test']' is an invalid value for attribute name.trigger-build-on-pr-label
|
||||||
|
- test
|
||||||
|
^
|
@ -0,0 +1,19 @@
|
|||||||
|
name: 'demo-multibranch-github-min'
|
||||||
|
project-type: multibranch
|
||||||
|
scm:
|
||||||
|
- github:
|
||||||
|
repo: 'foo'
|
||||||
|
repo-owner: 'johndoe'
|
||||||
|
|
||||||
|
property-strategies:
|
||||||
|
all-branches:
|
||||||
|
- suppress-scm-triggering: true
|
||||||
|
- pipeline-branch-durability-override: max-survivability
|
||||||
|
- trigger-build-on-pr-comment:
|
||||||
|
comment: "CI build!"
|
||||||
|
- trigger-build-on-pr-review:
|
||||||
|
allow-untrusted-users: false
|
||||||
|
- trigger-build-on-pr-update:
|
||||||
|
allow-untrusted-users: false
|
||||||
|
- trigger-build-on-pr-label:
|
||||||
|
- test
|
@ -0,0 +1,6 @@
|
|||||||
|
scm_github_comment_plugin_invalid_type006.yaml:18:19: For attribute 'trigger-build-on-pr-label'
|
||||||
|
- trigger-build-on-pr-label: true
|
||||||
|
^
|
||||||
|
scm_github_comment_plugin_invalid_type006.yaml:18:46: 'True' is an invalid value for attribute name.trigger-build-on-pr-label
|
||||||
|
- trigger-build-on-pr-label: true
|
||||||
|
^
|
@ -0,0 +1,18 @@
|
|||||||
|
name: 'demo-multibranch-github-min'
|
||||||
|
project-type: multibranch
|
||||||
|
scm:
|
||||||
|
- github:
|
||||||
|
repo: 'foo'
|
||||||
|
repo-owner: 'johndoe'
|
||||||
|
|
||||||
|
property-strategies:
|
||||||
|
all-branches:
|
||||||
|
- suppress-scm-triggering: true
|
||||||
|
- pipeline-branch-durability-override: max-survivability
|
||||||
|
- trigger-build-on-pr-comment:
|
||||||
|
comment: "CI build!"
|
||||||
|
- trigger-build-on-pr-review:
|
||||||
|
allow-untrusted-users: false
|
||||||
|
- trigger-build-on-pr-update:
|
||||||
|
allow-untrusted-users: false
|
||||||
|
- trigger-build-on-pr-label: true
|
@ -11,6 +11,7 @@ scm:
|
|||||||
- test
|
- test
|
||||||
- pipeline-branch-durability-override: max-survivability
|
- pipeline-branch-durability-override: max-survivability
|
||||||
- trigger-build-on-pr-comment: "Ci build!"
|
- trigger-build-on-pr-comment: "Ci build!"
|
||||||
|
- trigger-build-on-pr-label: false
|
||||||
- trigger-build-on-pr-review:
|
- trigger-build-on-pr-review:
|
||||||
allow-untrusted-users: false
|
allow-untrusted-users: false
|
||||||
- trigger-build-on-pr-update:
|
- trigger-build-on-pr-update:
|
||||||
|
@ -11,6 +11,7 @@ scm:
|
|||||||
suppression-strategy: suppress-webhooks
|
suppression-strategy: suppress-webhooks
|
||||||
- pipeline-branch-durability-override: max-survivability
|
- pipeline-branch-durability-override: max-survivability
|
||||||
- trigger-build-on-pr-comment: "Ci build!"
|
- trigger-build-on-pr-comment: "Ci build!"
|
||||||
|
- trigger-build-on-pr-label: false
|
||||||
- trigger-build-on-pr-review:
|
- trigger-build-on-pr-review:
|
||||||
allow-untrusted-users: false
|
allow-untrusted-users: false
|
||||||
- trigger-build-on-pr-update:
|
- trigger-build-on-pr-update:
|
||||||
|
@ -11,6 +11,7 @@ scm:
|
|||||||
branch-regex: ^.*test.*$
|
branch-regex: ^.*test.*$
|
||||||
- pipeline-branch-durability-override: max-survivability
|
- pipeline-branch-durability-override: max-survivability
|
||||||
- trigger-build-on-pr-comment: "Ci build!"
|
- trigger-build-on-pr-comment: "Ci build!"
|
||||||
|
- trigger-build-on-pr-label: false
|
||||||
- trigger-build-on-pr-review:
|
- trigger-build-on-pr-review:
|
||||||
allow-untrusted-users: false
|
allow-untrusted-users: false
|
||||||
- trigger-build-on-pr-update:
|
- trigger-build-on-pr-update:
|
||||||
|
@ -12,6 +12,7 @@ scm:
|
|||||||
branch-regex: ^$
|
branch-regex: ^$
|
||||||
- pipeline-branch-durability-override: max-survivability
|
- pipeline-branch-durability-override: max-survivability
|
||||||
- trigger-build-on-pr-comment: "Ci build!"
|
- trigger-build-on-pr-comment: "Ci build!"
|
||||||
|
- trigger-build-on-pr-label: false
|
||||||
- trigger-build-on-pr-review:
|
- trigger-build-on-pr-review:
|
||||||
allow-untrusted-users: false
|
allow-untrusted-users: false
|
||||||
- trigger-build-on-pr-update:
|
- trigger-build-on-pr-update:
|
||||||
|
@ -10,5 +10,6 @@ scm:
|
|||||||
- suppress-scm-triggering: true
|
- suppress-scm-triggering: true
|
||||||
- pipeline-branch-durability-override: max-survivability
|
- pipeline-branch-durability-override: max-survivability
|
||||||
- trigger-build-on-pr-comment: "Ci build!"
|
- trigger-build-on-pr-comment: "Ci build!"
|
||||||
|
- trigger-build-on-pr-label: false
|
||||||
- trigger-build-on-pr-review: false
|
- trigger-build-on-pr-review: false
|
||||||
- trigger-build-on-pr-update: false
|
- trigger-build-on-pr-update: false
|
||||||
|
@ -10,5 +10,6 @@ scm:
|
|||||||
- suppress-scm-triggering: true
|
- suppress-scm-triggering: true
|
||||||
- pipeline-branch-durability-override: max-survivability
|
- pipeline-branch-durability-override: max-survivability
|
||||||
- trigger-build-on-pr-comment: {}
|
- trigger-build-on-pr-comment: {}
|
||||||
|
- trigger-build-on-pr-label: {}
|
||||||
- trigger-build-on-pr-review: {}
|
- trigger-build-on-pr-review: {}
|
||||||
- trigger-build-on-pr-update: {}
|
- trigger-build-on-pr-update: {}
|
||||||
|
@ -10,5 +10,6 @@ scm:
|
|||||||
- suppress-scm-triggering: true
|
- suppress-scm-triggering: true
|
||||||
- pipeline-branch-durability-override: max-survivability
|
- pipeline-branch-durability-override: max-survivability
|
||||||
- trigger-build-on-pr-comment:
|
- trigger-build-on-pr-comment:
|
||||||
|
- trigger-build-on-pr-label:
|
||||||
- trigger-build-on-pr-review:
|
- trigger-build-on-pr-review:
|
||||||
- trigger-build-on-pr-update:
|
- trigger-build-on-pr-update:
|
||||||
|
@ -178,6 +178,11 @@
|
|||||||
<commentBody>Ci build!</commentBody>
|
<commentBody>Ci build!</commentBody>
|
||||||
<allowUntrusted>true</allowUntrusted>
|
<allowUntrusted>true</allowUntrusted>
|
||||||
</com.adobe.jenkins.github__pr__comment__build.TriggerPRCommentBranchProperty>
|
</com.adobe.jenkins.github__pr__comment__build.TriggerPRCommentBranchProperty>
|
||||||
|
<com.adobe.jenkins.github__pr__comment__build.TriggerPRLabelBranchProperty plugin="github-pr-comment-build">
|
||||||
|
<label>some label</label>
|
||||||
|
<allowUntrusted>false</allowUntrusted>
|
||||||
|
<minimumPermissions>WRITE</minimumPermissions>
|
||||||
|
</com.adobe.jenkins.github__pr__comment__build.TriggerPRLabelBranchProperty>
|
||||||
<com.adobe.jenkins.github__pr__comment__build.TriggerPRReviewBranchProperty plugin="github-pr-comment-build">
|
<com.adobe.jenkins.github__pr__comment__build.TriggerPRReviewBranchProperty plugin="github-pr-comment-build">
|
||||||
<allowUntrusted>true</allowUntrusted>
|
<allowUntrusted>true</allowUntrusted>
|
||||||
</com.adobe.jenkins.github__pr__comment__build.TriggerPRReviewBranchProperty>
|
</com.adobe.jenkins.github__pr__comment__build.TriggerPRReviewBranchProperty>
|
||||||
|
@ -52,6 +52,8 @@ scm:
|
|||||||
- trigger-build-on-pr-comment:
|
- trigger-build-on-pr-comment:
|
||||||
comment: "Ci build!"
|
comment: "Ci build!"
|
||||||
allow-untrusted-users: true
|
allow-untrusted-users: true
|
||||||
|
- trigger-build-on-pr-label:
|
||||||
|
label-regex: "some label"
|
||||||
- trigger-build-on-pr-review:
|
- trigger-build-on-pr-review:
|
||||||
allow-untrusted-users: true
|
allow-untrusted-users: true
|
||||||
- trigger-build-on-pr-update:
|
- trigger-build-on-pr-update:
|
||||||
|
@ -163,6 +163,11 @@
|
|||||||
<com.adobe.jenkins.github__pr__comment__build.TriggerPRCommentBranchProperty plugin="github-pr-comment-build">
|
<com.adobe.jenkins.github__pr__comment__build.TriggerPRCommentBranchProperty plugin="github-pr-comment-build">
|
||||||
<commentBody>Ci build!</commentBody>
|
<commentBody>Ci build!</commentBody>
|
||||||
</com.adobe.jenkins.github__pr__comment__build.TriggerPRCommentBranchProperty>
|
</com.adobe.jenkins.github__pr__comment__build.TriggerPRCommentBranchProperty>
|
||||||
|
<com.adobe.jenkins.github__pr__comment__build.TriggerPRLabelBranchProperty plugin="github-pr-comment-build">
|
||||||
|
<label>some label</label>
|
||||||
|
<allowUntrusted>false</allowUntrusted>
|
||||||
|
<minimumPermissions>WRITE</minimumPermissions>
|
||||||
|
</com.adobe.jenkins.github__pr__comment__build.TriggerPRLabelBranchProperty>
|
||||||
<com.adobe.jenkins.github__pr__comment__build.TriggerPRReviewBranchProperty plugin="github-pr-comment-build"/>
|
<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"/>
|
<com.adobe.jenkins.github__pr__comment__build.TriggerPRUpdateBranchProperty plugin="github-pr-comment-build"/>
|
||||||
</a>
|
</a>
|
||||||
|
@ -38,6 +38,7 @@ scm:
|
|||||||
- suppress-scm-triggering: true
|
- suppress-scm-triggering: true
|
||||||
- pipeline-branch-durability-override: max-survivability
|
- pipeline-branch-durability-override: max-survivability
|
||||||
- trigger-build-on-pr-comment: "Ci build!"
|
- trigger-build-on-pr-comment: "Ci build!"
|
||||||
|
- trigger-build-on-pr-label: "some label"
|
||||||
- trigger-build-on-pr-review: true
|
- trigger-build-on-pr-review: true
|
||||||
- trigger-build-on-pr-update: true
|
- trigger-build-on-pr-update: true
|
||||||
build-strategies:
|
build-strategies:
|
||||||
|
@ -65,6 +65,11 @@
|
|||||||
<com.adobe.jenkins.github__pr__comment__build.TriggerPRCommentBranchProperty plugin="github-pr-comment-build">
|
<com.adobe.jenkins.github__pr__comment__build.TriggerPRCommentBranchProperty plugin="github-pr-comment-build">
|
||||||
<commentBody>Ci build!</commentBody>
|
<commentBody>Ci build!</commentBody>
|
||||||
</com.adobe.jenkins.github__pr__comment__build.TriggerPRCommentBranchProperty>
|
</com.adobe.jenkins.github__pr__comment__build.TriggerPRCommentBranchProperty>
|
||||||
|
<com.adobe.jenkins.github__pr__comment__build.TriggerPRLabelBranchProperty plugin="github-pr-comment-build">
|
||||||
|
<label>some label</label>
|
||||||
|
<allowUntrusted>false</allowUntrusted>
|
||||||
|
<minimumPermissions>WRITE</minimumPermissions>
|
||||||
|
</com.adobe.jenkins.github__pr__comment__build.TriggerPRLabelBranchProperty>
|
||||||
<com.adobe.jenkins.github__pr__comment__build.TriggerPRReviewBranchProperty plugin="github-pr-comment-build"/>
|
<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"/>
|
<com.adobe.jenkins.github__pr__comment__build.TriggerPRUpdateBranchProperty plugin="github-pr-comment-build"/>
|
||||||
</a>
|
</a>
|
||||||
|
@ -12,5 +12,6 @@ scm:
|
|||||||
branch-regex: ^$
|
branch-regex: ^$
|
||||||
- pipeline-branch-durability-override: max-survivability
|
- pipeline-branch-durability-override: max-survivability
|
||||||
- trigger-build-on-pr-comment: "Ci build!"
|
- trigger-build-on-pr-comment: "Ci build!"
|
||||||
|
- trigger-build-on-pr-label: "some label"
|
||||||
- trigger-build-on-pr-review: true
|
- trigger-build-on-pr-review: true
|
||||||
- trigger-build-on-pr-update: true
|
- trigger-build-on-pr-update: true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user