From 11941c87f448ce525eec9a8ca77c00c2b119eee7 Mon Sep 17 00:00:00 2001 From: Barak Korren Date: Thu, 5 Jul 2018 10:02:58 +0300 Subject: [PATCH] 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 --- jenkins_jobs/modules/scm.py | 2 +- tests/scm/fixtures/git-extensions03.xml | 45 ++++++++++++++++++++++++ tests/scm/fixtures/git-extensions03.yaml | 16 +++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 tests/scm/fixtures/git-extensions03.xml create mode 100644 tests/scm/fixtures/git-extensions03.yaml diff --git a/jenkins_jobs/modules/scm.py b/jenkins_jobs/modules/scm.py index 54b597c67..c82d106e2 100644 --- a/jenkins_jobs/modules/scm.py +++ b/jenkins_jobs/modules/scm.py @@ -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': diff --git a/tests/scm/fixtures/git-extensions03.xml b/tests/scm/fixtures/git-extensions03.xml new file mode 100644 index 000000000..8f9fd2b9f --- /dev/null +++ b/tests/scm/fixtures/git-extensions03.xml @@ -0,0 +1,45 @@ + + + + 2 + + + origin + +refs/heads/*:refs/remotes/origin/* + https://example.com/project.git + + + + + master + + + false + false + false + false + Default + + + + + + + go/src/github.com/foo/example + + + alice@example.com +bob@example.com + + + something_special + + + + + + + http://github.com/foo/example.git + + + diff --git a/tests/scm/fixtures/git-extensions03.yaml b/tests/scm/fixtures/git-extensions03.yaml new file mode 100644 index 000000000..98eec9c92 --- /dev/null +++ b/tests/scm/fixtures/git-extensions03.yaml @@ -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