multibranch: Add refspecs trait to bitbucket scm
Change-Id: Id0d65a89d044cbf0c7455f5c79bfaae226f74ada
This commit is contained in:
parent
5a98ebb8bb
commit
74d2e1302c
@ -401,6 +401,7 @@ def bitbucket_scm(xml_parent, data):
|
||||
origin/develop/new-feature will be checked out to a local branch
|
||||
named develop/newfeature.
|
||||
Requires the :jenkins-plugins:`Git Plugin <git>`.
|
||||
:arg list(str) refspecs: Which refspecs to look for.
|
||||
:arg dict checkout-over-ssh: Checkout repo over ssh.
|
||||
|
||||
* **credentials** ('str'): Credentials to use for
|
||||
@ -480,6 +481,25 @@ def bitbucket_scm(xml_parent, data):
|
||||
helpers.convert_mapping_to_xml(source, data, mapping_optional, fail_required=False)
|
||||
|
||||
traits = XML.SubElement(source, "traits")
|
||||
|
||||
if data.get("refspecs"):
|
||||
refspec_trait = XML.SubElement(
|
||||
traits,
|
||||
"jenkins.plugins.git.traits.RefSpecsSCMSourceTrait",
|
||||
{"plugin": "git"},
|
||||
)
|
||||
templates = XML.SubElement(refspec_trait, "templates")
|
||||
refspecs = data.get("refspecs")
|
||||
for refspec in refspecs:
|
||||
e = XML.SubElement(
|
||||
templates,
|
||||
(
|
||||
"jenkins.plugins.git.traits"
|
||||
".RefSpecsSCMSourceTrait_-RefSpecTemplate"
|
||||
),
|
||||
)
|
||||
XML.SubElement(e, "value").text = refspec
|
||||
|
||||
if data.get("discover-tags", False):
|
||||
XML.SubElement(
|
||||
traits, "com.cloudbees.jenkins.plugins.bitbucket.TagDiscoveryTrait"
|
||||
|
@ -38,6 +38,16 @@
|
||||
<credentialsId>secret</credentialsId>
|
||||
<serverUrl>https://bitbucket.example.com:8080</serverUrl>
|
||||
<traits>
|
||||
<jenkins.plugins.git.traits.RefSpecsSCMSourceTrait plugin="git">
|
||||
<templates>
|
||||
<jenkins.plugins.git.traits.RefSpecsSCMSourceTrait_-RefSpecTemplate>
|
||||
<value>+refs/heads/*:refs/remotes/@{remote}/*</value>
|
||||
</jenkins.plugins.git.traits.RefSpecsSCMSourceTrait_-RefSpecTemplate>
|
||||
<jenkins.plugins.git.traits.RefSpecsSCMSourceTrait_-RefSpecTemplate>
|
||||
<value>+refs/tags/*:refs/remotes/@{remote}/*</value>
|
||||
</jenkins.plugins.git.traits.RefSpecsSCMSourceTrait_-RefSpecTemplate>
|
||||
</templates>
|
||||
</jenkins.plugins.git.traits.RefSpecsSCMSourceTrait>
|
||||
<com.cloudbees.jenkins.plugins.bitbucket.TagDiscoveryTrait/>
|
||||
<jenkins.scm.impl.trait.RegexSCMHeadFilterTrait>
|
||||
<regex>master|\d+\.\d+</regex>
|
||||
|
@ -23,6 +23,9 @@ scm:
|
||||
all-branches:
|
||||
- suppress-scm-triggering: true
|
||||
- pipeline-branch-durability-override: max-survivability
|
||||
refspecs:
|
||||
- '+refs/heads/*:refs/remotes/@{remote}/*'
|
||||
- '+refs/tags/*:refs/remotes/@{remote}/*'
|
||||
build-strategies:
|
||||
- tags:
|
||||
ignore-tags-newer-than: 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user