diff --git a/jenkins_jobs/modules/scm.py b/jenkins_jobs/modules/scm.py index 0336330ae..f8bd98250 100644 --- a/jenkins_jobs/modules/scm.py +++ b/jenkins_jobs/modules/scm.py @@ -59,6 +59,7 @@ def git(self, xml_parent, data): when polling for changes. (if polling is enabled) :arg list(str) included-regions: list of file/folders to include :arg list(str) excluded-regions: list of file/folders to exclude + :arg str local-branch: Checkout/merge to local branch :arg dict merge: :merge: * **remote** (`string`) - name of repo that contains branch to @@ -198,6 +199,10 @@ def git(self, xml_parent, data): xe.text = str(val).lower() else: xe.text = val + + if 'local-branch' in data: + XML.SubElement(scm, 'localBranch').text = data['local-branch'] + browser = data.get('browser', 'auto') browserdict = {'githubweb': 'GithubWeb', 'fisheye': 'FisheyeGitRepositoryBrowser', diff --git a/tests/scm/fixtures/local-branch001.xml b/tests/scm/fixtures/local-branch001.xml new file mode 100644 index 000000000..b272c0534 --- /dev/null +++ b/tests/scm/fixtures/local-branch001.xml @@ -0,0 +1,38 @@ + + + + 2 + + + origin + +refs/heads/*:refs/remotes/origin/* + https://github.com/openstack-infra/jenkins-job-builder.git + + + + + master + + + + + false + false + false + false + false + true + false + false + Default + + + + + + false + + false + master + + diff --git a/tests/scm/fixtures/local-branch001.yaml b/tests/scm/fixtures/local-branch001.yaml new file mode 100644 index 000000000..ca2da69f1 --- /dev/null +++ b/tests/scm/fixtures/local-branch001.yaml @@ -0,0 +1,6 @@ +scm: + - git: + url: https://github.com/openstack-infra/jenkins-job-builder.git + branches: + - master + local-branch: master