multibranch-bitbucket: discover strategies
Can specify discover-branch and discover-pr-origin strategies. Changes are based on existing code for multibranch-github implementation. Change-Id: I8e5e29df9d04339c19a61180143bc0e14395aa58
This commit is contained in:
parent
d1e2f75ec5
commit
2d6a0c7a53
@ -305,6 +305,13 @@ def bitbucket_scm(xml_parent, data):
|
||||
:arg str head-filter-regex: A regular expression for filtering
|
||||
discovered source branches. Requires the :jenkins-wiki:`SCM API Plugin
|
||||
<SCM+API+Plugin>`.
|
||||
:arg str discovery-branch: Discovers branches on the repository.
|
||||
Valid options: ex-pr, only-pr, all.
|
||||
Value is not specified by default.
|
||||
:arg str discover-pr-origin: Discovers pull requests where the origin
|
||||
repository is the same as the target repository.
|
||||
Valid options: mergeOnly, headOnly, mergeAndHead.
|
||||
Value is not specified by default.
|
||||
|
||||
Minimal Example:
|
||||
|
||||
@ -344,6 +351,35 @@ def bitbucket_scm(xml_parent, data):
|
||||
'jenkins.scm.impl.trait.RegexSCMHeadFilterTrait')
|
||||
XML.SubElement(rshf, 'regex').text = data.get('head-filter-regex')
|
||||
|
||||
if data.get('discover-pr-origin', None):
|
||||
dpro = XML.SubElement(traits,
|
||||
'com.cloudbees.jenkins.plugins.bitbucket'
|
||||
'.OriginPullRequestDiscoveryTrait')
|
||||
dpro_strategies = {
|
||||
'mergeOnly': '1',
|
||||
'headOnly': '2',
|
||||
'mergeAndHead': '3'
|
||||
}
|
||||
dpro_mapping = [
|
||||
('discover-pr-origin', 'strategyId', None, dpro_strategies)
|
||||
]
|
||||
helpers.convert_mapping_to_xml(
|
||||
dpro, data, dpro_mapping, fail_required=True)
|
||||
|
||||
if data.get('discover-branch', None):
|
||||
dbr = XML.SubElement(traits,
|
||||
'com.cloudbees.jenkins.plugins.bitbucket.BranchDiscoveryTrait')
|
||||
dbr_strategies = {
|
||||
'ex-pr': '1',
|
||||
'only-pr': '2',
|
||||
'all': '3'
|
||||
}
|
||||
dbr_mapping = [
|
||||
('discover-branch', 'strategyId', None, dbr_strategies)
|
||||
]
|
||||
helpers.convert_mapping_to_xml(
|
||||
dbr, data, dbr_mapping, fail_required=True)
|
||||
|
||||
|
||||
def gerrit_scm(xml_parent, data):
|
||||
"""Configure Gerrit SCM
|
||||
|
@ -42,6 +42,12 @@
|
||||
<jenkins.scm.impl.trait.RegexSCMHeadFilterTrait>
|
||||
<regex>master|\d+\.\d+</regex>
|
||||
</jenkins.scm.impl.trait.RegexSCMHeadFilterTrait>
|
||||
<com.cloudbees.jenkins.plugins.bitbucket.OriginPullRequestDiscoveryTrait>
|
||||
<strategyId>2</strategyId>
|
||||
</com.cloudbees.jenkins.plugins.bitbucket.OriginPullRequestDiscoveryTrait>
|
||||
<com.cloudbees.jenkins.plugins.bitbucket.BranchDiscoveryTrait>
|
||||
<strategyId>3</strategyId>
|
||||
</com.cloudbees.jenkins.plugins.bitbucket.BranchDiscoveryTrait>
|
||||
</traits>
|
||||
</source>
|
||||
</jenkins.branch.BranchSource>
|
||||
|
@ -9,3 +9,6 @@ scm:
|
||||
server-url: https://bitbucket.example.com:8080
|
||||
discover-tags: true
|
||||
head-filter-regex: 'master|\d+\.\d+'
|
||||
discover-pr-origin: headOnly
|
||||
discover-branch: all
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user