Merge "multibranch: Add refspecs trait to bitbucket scm"

This commit is contained in:
Zuul 2020-09-08 13:57:43 +00:00 committed by Gerrit Code Review
commit afc2b6fd42
3 changed files with 33 additions and 0 deletions
jenkins_jobs/modules
tests/multibranch/fixtures

@ -403,6 +403,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
@ -482,6 +483,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.plugins.git.traits.GitLFSPullTrait plugin="git">
<extension class="hudson.plugins.git.extensions.impl.GitLFSPull"/>

@ -24,6 +24,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