diff --git a/jenkins_jobs/modules/project_multibranch.py b/jenkins_jobs/modules/project_multibranch.py
index 292423b4f..d6447cb8c 100644
--- a/jenkins_jobs/modules/project_multibranch.py
+++ b/jenkins_jobs/modules/project_multibranch.py
@@ -296,6 +296,9 @@ def bitbucket_scm(xml_parent, data):
User Account. (required)
:arg str repo: The BitBucket repo. (required)
+ :arg bool discover-tags: Discovers tags on the repository.
+ (default false)
+
Minimal Example:
.. literalinclude::
@@ -324,7 +327,10 @@ def bitbucket_scm(xml_parent, data):
helpers.convert_mapping_to_xml(
source, data, mapping_optional, fail_required=False)
- XML.SubElement(source, 'traits')
+ traits = XML.SubElement(source, 'traits')
+ if data.get('discover-tags', False):
+ XML.SubElement(traits,
+ 'com.cloudbees.jenkins.plugins.bitbucket.TagDiscoveryTrait')
def gerrit_scm(xml_parent, data):
@@ -413,6 +419,8 @@ def git_scm(xml_parent, data):
:arg bool discover-branches: Discovers branches on the repository.
(default true)
+ :arg bool discover-tags: Discovers tags on the repository.
+ (default false)
:arg bool ignore-on-push-notifications: If a job should not trigger upon
push notifications. (default false)
@@ -446,6 +454,9 @@ def git_scm(xml_parent, data):
if data.get('discover-branches', True):
XML.SubElement(traits, ''.join([traits_path, '.BranchDiscoveryTrait']))
+ if data.get('discover-tags', False):
+ XML.SubElement(traits, ''.join([traits_path, '.TagDiscoveryTrait']))
+
if data.get('ignore-on-push-notifications', False):
XML.SubElement(
traits, ''.join([traits_path, '.IgnoreOnPushNotificationTrait']))
@@ -476,6 +487,8 @@ def github_scm(xml_parent, data):
:arg str discover-pr-origin: Discovers pull requests where the origin
repository is the same as the target repository.
Valid options: merge-current, current, both. (default 'merge-current')
+ :arg bool discover-tags: Discovers tags on the repository.
+ (default false)
Minimal Example:
@@ -526,6 +539,13 @@ def github_scm(xml_parent, data):
helpers.convert_mapping_to_xml(
bd, data, bd_mapping, fail_required=True)
+ if data.get('discover-tags', False):
+ XML.SubElement(
+ traits, ''.join([
+ github_path_dscore, '.TagDiscoveryTrait'
+ ])
+ )
+
if data.get('discover-pr-forks-strategy', 'merged-current'):
dprf = XML.SubElement(
traits, ''.join([
diff --git a/tests/multibranch/fixtures/scm_bitbucket_full.xml b/tests/multibranch/fixtures/scm_bitbucket_full.xml
index f1a73421b..9a4b78a96 100644
--- a/tests/multibranch/fixtures/scm_bitbucket_full.xml
+++ b/tests/multibranch/fixtures/scm_bitbucket_full.xml
@@ -36,7 +36,9 @@
SANDBOX
test
secret
-
+
+
+
diff --git a/tests/multibranch/fixtures/scm_bitbucket_full.yaml b/tests/multibranch/fixtures/scm_bitbucket_full.yaml
index b9d3ca116..50138255f 100644
--- a/tests/multibranch/fixtures/scm_bitbucket_full.yaml
+++ b/tests/multibranch/fixtures/scm_bitbucket_full.yaml
@@ -5,3 +5,4 @@ scm:
credentials-id: 'secret'
repo-owner: 'SANDBOX'
repo: 'test'
+ discover-tags: true
diff --git a/tests/multibranch/fixtures/scm_git_full.xml b/tests/multibranch/fixtures/scm_git_full.xml
index 42aa899fa..0a125a108 100644
--- a/tests/multibranch/fixtures/scm_git_full.xml
+++ b/tests/multibranch/fixtures/scm_git_full.xml
@@ -36,6 +36,7 @@
https://example.com/jonhndoe/keep-frontend.git
secret
+
diff --git a/tests/multibranch/fixtures/scm_git_full.yaml b/tests/multibranch/fixtures/scm_git_full.yaml
index a8087cff7..13735c962 100644
--- a/tests/multibranch/fixtures/scm_git_full.yaml
+++ b/tests/multibranch/fixtures/scm_git_full.yaml
@@ -6,3 +6,4 @@ scm:
credentials-id: secret
discover-branches: false
ignore-on-push-notifications: true
+ discover-tags: true
diff --git a/tests/multibranch/fixtures/scm_github_full.xml b/tests/multibranch/fixtures/scm_github_full.xml
index b61d497e4..672967376 100644
--- a/tests/multibranch/fixtures/scm_github_full.xml
+++ b/tests/multibranch/fixtures/scm_github_full.xml
@@ -41,6 +41,7 @@
3
+
3
diff --git a/tests/multibranch/fixtures/scm_github_full.yaml b/tests/multibranch/fixtures/scm_github_full.yaml
index 157d429ff..c35ca97cc 100644
--- a/tests/multibranch/fixtures/scm_github_full.yaml
+++ b/tests/multibranch/fixtures/scm_github_full.yaml
@@ -10,3 +10,4 @@ scm:
discover-pr-forks-strategy: both
discover-pr-forks-trust: everyone
discover-pr-origin: both
+ discover-tags: true