From 009b362968385ce895099ea463965a754b3015b9 Mon Sep 17 00:00:00 2001 From: Kyle Rockman Date: Wed, 12 Nov 2014 11:26:53 -0600 Subject: [PATCH] add support to git for changelog against branch added support for another extension type, and fix how extensions are populated to xml Change-Id: Ic9cf21a268d4ee3fb9b9efdee65c3d49e0cdb31e Signed-off-by: Kyle Rockman --- jenkins_jobs/modules/scm.py | 24 +++++++- .../fixtures/allow_duplicates001.xml | 1 + tests/duplicates/fixtures/allow_macros001.xml | 1 + .../duplicates/fixtures/allow_projects001.xml | 1 + .../fixtures/allow_templates001.xml | 1 + tests/duplicates/fixtures/duplicates001.xml | 2 + tests/duplicates/fixtures/duplicates002.xml | 2 + tests/macros/scm/multi-scms001.xml | 2 + tests/macros/scm/multi-scms002.xml | 1 + tests/macros/scm/scm002.xml | 1 + tests/scm/fixtures/git-ignore-notify01.xml | 1 + tests/scm/fixtures/git-ignore-notify02.xml | 1 + tests/scm/fixtures/git-ignore-notify03.xml | 1 + tests/scm/fixtures/git-multiple-remotes.xml | 1 + tests/scm/fixtures/git-shallow-clone01.xml | 1 + tests/scm/fixtures/git-shallow-clone02.xml | 1 + tests/scm/fixtures/git-shallow-clone03.xml | 1 + tests/scm/fixtures/git002.xml | 55 +++++++++++++++++++ tests/scm/fixtures/git002.yaml | 12 ++++ tests/scm/fixtures/gitlab.xml | 1 + tests/scm/fixtures/local-branch001.xml | 1 + tests/scm/fixtures/stash.xml | 1 + tests/yamlparser/fixtures/complete001.xml | 1 + .../fixtures/scm_remote_deep_bug.xml | 1 + 24 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 tests/scm/fixtures/git002.xml create mode 100644 tests/scm/fixtures/git002.yaml diff --git a/jenkins_jobs/modules/scm.py b/jenkins_jobs/modules/scm.py index 91ae0706f..c250d8b49 100644 --- a/jenkins_jobs/modules/scm.py +++ b/jenkins_jobs/modules/scm.py @@ -96,7 +96,17 @@ remoteName/\*') (default 'default') :arg str git-config-name: Configure name for Git clone (optional) :arg str git-config-email: Configure email for Git clone (optional) - :arg str timeout: Timeout for git commands in minutes (optional) + + + :extensions: + :arg dict changelog-against: + :changelog-against: + * **remote** (`string`) - name of repo that contains branch to + create changelog against (default 'origin') + * **branch** (`string`) - name of the branch to create + create changelog against (default 'master') + + :arg str timeout: Timeout for git commands in minutes (optional) :browser values: :auto: @@ -223,9 +233,17 @@ remoteName/\*') if 'local-branch' in data: XML.SubElement(scm, 'localBranch').text = data['local-branch'] + exts_node = XML.SubElement(scm, 'extensions') + if 'changelog-against' in data: + ext_name = 'hudson.plugins.git.extensions.impl.ChangelogToBranch' + ext = XML.SubElement(exts_node, ext_name) + opts = XML.SubElement(ext, 'options') + change_remote = data['changelog-against'].get('remote', 'origin') + change_branch = data['changelog-against'].get('branch', 'master') + XML.SubElement(opts, 'compareRemote').text = change_remote + XML.SubElement(opts, 'compareTarget').text = change_branch if 'timeout' in data: - ext = XML.SubElement(scm, 'extensions') - co = XML.SubElement(ext, + co = XML.SubElement(exts_node, 'hudson.plugins.git.extensions.impl.' 'CheckoutOption') XML.SubElement(co, 'timeout').text = str(data['timeout']) diff --git a/tests/duplicates/fixtures/allow_duplicates001.xml b/tests/duplicates/fixtures/allow_duplicates001.xml index e059d06ce..7bc48b8c6 100644 --- a/tests/duplicates/fixtures/allow_duplicates001.xml +++ b/tests/duplicates/fixtures/allow_duplicates001.xml @@ -42,6 +42,7 @@ false false + diff --git a/tests/duplicates/fixtures/allow_macros001.xml b/tests/duplicates/fixtures/allow_macros001.xml index c24d57210..2fb2b2749 100644 --- a/tests/duplicates/fixtures/allow_macros001.xml +++ b/tests/duplicates/fixtures/allow_macros001.xml @@ -42,6 +42,7 @@ false false + diff --git a/tests/duplicates/fixtures/allow_projects001.xml b/tests/duplicates/fixtures/allow_projects001.xml index 0b4b1a1b3..23942c9e4 100644 --- a/tests/duplicates/fixtures/allow_projects001.xml +++ b/tests/duplicates/fixtures/allow_projects001.xml @@ -42,6 +42,7 @@ false false + diff --git a/tests/duplicates/fixtures/allow_templates001.xml b/tests/duplicates/fixtures/allow_templates001.xml index 0b4b1a1b3..23942c9e4 100644 --- a/tests/duplicates/fixtures/allow_templates001.xml +++ b/tests/duplicates/fixtures/allow_templates001.xml @@ -42,6 +42,7 @@ false false + diff --git a/tests/duplicates/fixtures/duplicates001.xml b/tests/duplicates/fixtures/duplicates001.xml index 6f2e535ab..c7ead7a95 100644 --- a/tests/duplicates/fixtures/duplicates001.xml +++ b/tests/duplicates/fixtures/duplicates001.xml @@ -42,6 +42,7 @@ false false + @@ -91,6 +92,7 @@ false false + diff --git a/tests/duplicates/fixtures/duplicates002.xml b/tests/duplicates/fixtures/duplicates002.xml index 4c285c547..0dccf9cee 100644 --- a/tests/duplicates/fixtures/duplicates002.xml +++ b/tests/duplicates/fixtures/duplicates002.xml @@ -42,6 +42,7 @@ false false + @@ -91,6 +92,7 @@ false false + diff --git a/tests/macros/scm/multi-scms001.xml b/tests/macros/scm/multi-scms001.xml index 741f9ea1c..433e8af49 100644 --- a/tests/macros/scm/multi-scms001.xml +++ b/tests/macros/scm/multi-scms001.xml @@ -44,6 +44,7 @@ false false + 2 @@ -79,6 +80,7 @@ false false + diff --git a/tests/macros/scm/multi-scms002.xml b/tests/macros/scm/multi-scms002.xml index 480a4d352..517fe55af 100644 --- a/tests/macros/scm/multi-scms002.xml +++ b/tests/macros/scm/multi-scms002.xml @@ -56,6 +56,7 @@ false false + diff --git a/tests/macros/scm/scm002.xml b/tests/macros/scm/scm002.xml index 3c3c2f46e..69df57c62 100644 --- a/tests/macros/scm/scm002.xml +++ b/tests/macros/scm/scm002.xml @@ -42,6 +42,7 @@ false false + diff --git a/tests/scm/fixtures/git-ignore-notify01.xml b/tests/scm/fixtures/git-ignore-notify01.xml index 2e3bd0df3..32fb2a67e 100644 --- a/tests/scm/fixtures/git-ignore-notify01.xml +++ b/tests/scm/fixtures/git-ignore-notify01.xml @@ -34,5 +34,6 @@ false true + diff --git a/tests/scm/fixtures/git-ignore-notify02.xml b/tests/scm/fixtures/git-ignore-notify02.xml index 5b43eef78..d2fe74cd3 100644 --- a/tests/scm/fixtures/git-ignore-notify02.xml +++ b/tests/scm/fixtures/git-ignore-notify02.xml @@ -34,5 +34,6 @@ false false + diff --git a/tests/scm/fixtures/git-ignore-notify03.xml b/tests/scm/fixtures/git-ignore-notify03.xml index 5b43eef78..d2fe74cd3 100644 --- a/tests/scm/fixtures/git-ignore-notify03.xml +++ b/tests/scm/fixtures/git-ignore-notify03.xml @@ -34,5 +34,6 @@ false false + diff --git a/tests/scm/fixtures/git-multiple-remotes.xml b/tests/scm/fixtures/git-multiple-remotes.xml index 76a576771..18cbdf6e7 100644 --- a/tests/scm/fixtures/git-multiple-remotes.xml +++ b/tests/scm/fixtures/git-multiple-remotes.xml @@ -40,5 +40,6 @@ false false + diff --git a/tests/scm/fixtures/git-shallow-clone01.xml b/tests/scm/fixtures/git-shallow-clone01.xml index e11a56f20..4fced0d27 100644 --- a/tests/scm/fixtures/git-shallow-clone01.xml +++ b/tests/scm/fixtures/git-shallow-clone01.xml @@ -35,5 +35,6 @@ true false + diff --git a/tests/scm/fixtures/git-shallow-clone02.xml b/tests/scm/fixtures/git-shallow-clone02.xml index 5b43eef78..d2fe74cd3 100644 --- a/tests/scm/fixtures/git-shallow-clone02.xml +++ b/tests/scm/fixtures/git-shallow-clone02.xml @@ -34,5 +34,6 @@ false false + diff --git a/tests/scm/fixtures/git-shallow-clone03.xml b/tests/scm/fixtures/git-shallow-clone03.xml index 5b43eef78..d2fe74cd3 100644 --- a/tests/scm/fixtures/git-shallow-clone03.xml +++ b/tests/scm/fixtures/git-shallow-clone03.xml @@ -34,5 +34,6 @@ false false + diff --git a/tests/scm/fixtures/git002.xml b/tests/scm/fixtures/git002.xml new file mode 100644 index 000000000..61d9b41c6 --- /dev/null +++ b/tests/scm/fixtures/git002.xml @@ -0,0 +1,55 @@ + + + + 2 + + + origin + +refs/heads/*:refs/remotes/origin/* + https://example.com/project.git + + + + + master + + + stable + + + + + false + false + false + false + false + true + false + false + Default + + + + + + false + + false + false + + + + origin + master + + + + 20 + + + + http://github.com/foo/example.git + + + diff --git a/tests/scm/fixtures/git002.yaml b/tests/scm/fixtures/git002.yaml new file mode 100644 index 000000000..9376df58f --- /dev/null +++ b/tests/scm/fixtures/git002.yaml @@ -0,0 +1,12 @@ +scm: + - git: + url: https://example.com/project.git + branches: + - master + - stable + browser: githubweb + browser-url: http://github.com/foo/example.git + timeout: 20 + changelog-against: + remote: origin + branch: master diff --git a/tests/scm/fixtures/gitlab.xml b/tests/scm/fixtures/gitlab.xml index 5f3cee06c..3288d2039 100644 --- a/tests/scm/fixtures/gitlab.xml +++ b/tests/scm/fixtures/gitlab.xml @@ -34,6 +34,7 @@ false false + https://gitlab.example.com/foo/bar/ 5.2 diff --git a/tests/scm/fixtures/local-branch001.xml b/tests/scm/fixtures/local-branch001.xml index c47b437bf..d2d919f2c 100644 --- a/tests/scm/fixtures/local-branch001.xml +++ b/tests/scm/fixtures/local-branch001.xml @@ -35,5 +35,6 @@ false false master + diff --git a/tests/scm/fixtures/stash.xml b/tests/scm/fixtures/stash.xml index 6c039e4da..f347d2b29 100644 --- a/tests/scm/fixtures/stash.xml +++ b/tests/scm/fixtures/stash.xml @@ -34,6 +34,7 @@ false false + https://stash.example.com/projects/foo/repos/bar/ diff --git a/tests/yamlparser/fixtures/complete001.xml b/tests/yamlparser/fixtures/complete001.xml index 5e6ee427c..6fe64b899 100644 --- a/tests/yamlparser/fixtures/complete001.xml +++ b/tests/yamlparser/fixtures/complete001.xml @@ -42,6 +42,7 @@ false false + http://review.openstack.org/gitweb?p=openstack-infra/jenkins-job-builder.git diff --git a/tests/yamlparser/fixtures/scm_remote_deep_bug.xml b/tests/yamlparser/fixtures/scm_remote_deep_bug.xml index b267a116f..e80600cc7 100644 --- a/tests/yamlparser/fixtures/scm_remote_deep_bug.xml +++ b/tests/yamlparser/fixtures/scm_remote_deep_bug.xml @@ -42,6 +42,7 @@ false false +