Fix bug in Git 'skip-tag' backwards compatibility

Using the (deprecated) 'skip-tag' option in Git  SCM did not work as
expected, despite code in place to maintain compatibility with it.

This needs to work to allow smooth transition for projects from JJB 1.x
to 2.x.

Also added a test case to expose the issue.

Change-Id: I90230f9fe97757bcc70e35b829fc887839a19e57
Signed-off-by: Barak Korren <bkorren@redhat.com>
This commit is contained in:
Barak Korren 2018-07-05 10:02:58 +03:00
parent 637676375a
commit 11941c87f4
3 changed files with 62 additions and 1 deletions

View File

@ -432,7 +432,7 @@ def git(registry, xml_parent, data):
# The default value of per-build-tag is False if skip-tag is not set,
# so we set the default value of skip-tag to True.
per_build_tag_default = False
if str(data.get('skip-tag', True)).lower == 'false':
if str(data.get('skip-tag', True)).lower() == 'false':
per_build_tag_default = True
if str(data.get('per-build-tag',
per_build_tag_default)).lower() == 'true':

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<scm class="hudson.plugins.git.GitSCM">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<name>origin</name>
<refspec>+refs/heads/*:refs/remotes/origin/*</refspec>
<url>https://example.com/project.git</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>master</name>
</hudson.plugins.git.BranchSpec>
</branches>
<disableSubmodules>false</disableSubmodules>
<recursiveSubmodules>false</recursiveSubmodules>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<remotePoll>false</remotePoll>
<gitTool>Default</gitTool>
<submoduleCfg class="list"/>
<reference/>
<gitConfigName/>
<gitConfigEmail/>
<extensions>
<hudson.plugins.git.extensions.impl.RelativeTargetDirectory>
<relativeTargetDir>go/src/github.com/foo/example</relativeTargetDir>
</hudson.plugins.git.extensions.impl.RelativeTargetDirectory>
<hudson.plugins.git.extensions.impl.UserExclusion>
<excludedUsers>alice@example.com
bob@example.com</excludedUsers>
</hudson.plugins.git.extensions.impl.UserExclusion>
<hudson.plugins.git.extensions.impl.ScmName>
<name>something_special</name>
</hudson.plugins.git.extensions.impl.ScmName>
<hudson.plugins.git.extensions.impl.PerBuildTag/>
<hudson.plugins.git.extensions.impl.PruneStaleBranch/>
<hudson.plugins.git.extensions.impl.AuthorInChangelog/>
</extensions>
<browser class="hudson.plugins.git.browser.GithubWeb">
<url>http://github.com/foo/example.git</url>
</browser>
</scm>
</project>

View File

@ -0,0 +1,16 @@
scm:
- git:
url: https://example.com/project.git
branches:
- master
browser: githubweb
browser-url: http://github.com/foo/example.git
basedir: 'go/src/github.com/foo/example'
excluded-users:
- alice@example.com
- bob@example.com
skip-tag: false
prune: true
scm-name: something_special
use-author: true
wipe-workspace: false