Add refspecs trait for github SCM

Change-Id: Ibdcd5621fa1d030cda26f29cadb3ae4c3c3f3704
Signed-off-by: Anna Tikhonova <anna.m.tikhonova@gmail.com>
This commit is contained in:
Anna Tikhonova 2020-12-21 20:56:07 +03:00 committed by Vladimir Kuklin
parent 118ac858c4
commit c12e41844c
3 changed files with 28 additions and 0 deletions

View File

@ -930,6 +930,7 @@ def github_scm(xml_parent, data):
notifications on pull requests (default false) (Requires the
:jenkins-plugins:`GitHub Branch Source Plugin
<disable-github-multibranch-status>`.)
* **refspecs** (`list(str)`): Which refspecs to fetch.
* **submodule** (`dict`)
* **disable** (`bool`) - By disabling support for submodules you
can still keep using basic git plugin functionality and just have
@ -1085,6 +1086,24 @@ def github_scm(xml_parent, data):
# - use-author
git_extensions(traits, data)
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
# github-only extensions
disable_github_status_path_dscore = (
"com.adobe.jenkins.disable__github__multibranch__status"

View File

@ -103,6 +103,13 @@
<jenkins.plugins.git.traits.AuthorInChangelogTrait>
<extension class="hudson.plugins.git.extensions.impl.AuthorInChangelog"/>
</jenkins.plugins.git.traits.AuthorInChangelogTrait>
<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>
</templates>
</jenkins.plugins.git.traits.RefSpecsSCMSourceTrait>
<com.adobe.jenkins.disable__github__multibranch__status.DisableStatusUpdateTrait plugin="disable-github-multibranch-status"/>
</traits>
</source>

View File

@ -66,6 +66,8 @@ scm:
depth: 3
do-not-fetch-tags: true
disable-pr-notifications: true
refspecs:
- '+refs/heads/*:refs/remotes/@{remote}/*'
submodule:
disable: false
recursive: true