configure git PathRestriction as an extension
The git plugin restructured PathRestriction moved to an extension in 2013 or so. Backwards compatibility code (GitSCMBackwardCompatibility) kept the old xml working, but it is cleaner if what jenkins-job-builder emits matches what jenkins uses. Change-Id: I7f34a650586ba394eed4db345d8ce831d5791559
This commit is contained in:
parent
d4bff3529d
commit
1fe7f9cc83
@ -257,12 +257,6 @@ remoteName/\*')
|
||||
XML.SubElement(bspec, 'name').text = branch
|
||||
excluded_users = '\n'.join(data.get('excluded-users', []))
|
||||
XML.SubElement(scm, 'excludedUsers').text = excluded_users
|
||||
if 'included-regions' in data:
|
||||
include_string = '\n'.join(data['included-regions'])
|
||||
XML.SubElement(scm, 'includedRegions').text = include_string
|
||||
if 'excluded-regions' in data:
|
||||
exclude_string = '\n'.join(data['excluded-regions'])
|
||||
XML.SubElement(scm, 'excludedRegions').text = exclude_string
|
||||
if 'merge' in data:
|
||||
merge = data['merge']
|
||||
merge_strategies = ['default', 'resolve', 'recursive', 'octopus',
|
||||
@ -322,6 +316,16 @@ remoteName/\*')
|
||||
|
||||
exts_node = XML.SubElement(scm, 'extensions')
|
||||
impl_prefix = 'hudson.plugins.git.extensions.impl.'
|
||||
if 'included-regions' in data or 'excluded-regions' in data:
|
||||
ext_name = XML.SubElement(exts_node,
|
||||
'hudson.plugins.git.extensions.impl.'
|
||||
'PathRestriction')
|
||||
if 'included-regions' in data:
|
||||
include_string = '\n'.join(data['included-regions'])
|
||||
XML.SubElement(ext_name, 'includedRegions').text = include_string
|
||||
if 'excluded-regions' in data:
|
||||
exclude_string = '\n'.join(data['excluded-regions'])
|
||||
XML.SubElement(ext_name, 'excludedRegions').text = exclude_string
|
||||
if 'changelog-against' in data:
|
||||
ext_name = impl_prefix + 'ChangelogToBranch'
|
||||
ext = XML.SubElement(exts_node, ext_name)
|
||||
|
44
tests/scm/fixtures/git-polling-path-restriction01.xml
Normal file
44
tests/scm/fixtures/git-polling-path-restriction01.xml
Normal file
@ -0,0 +1,44 @@
|
||||
<?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://github.com/openstack-infra/jenkins-job-builder.git</url>
|
||||
</hudson.plugins.git.UserRemoteConfig>
|
||||
</userRemoteConfigs>
|
||||
<branches>
|
||||
<hudson.plugins.git.BranchSpec>
|
||||
<name>**</name>
|
||||
</hudson.plugins.git.BranchSpec>
|
||||
</branches>
|
||||
<excludedUsers/>
|
||||
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
|
||||
<disableSubmodules>false</disableSubmodules>
|
||||
<recursiveSubmodules>false</recursiveSubmodules>
|
||||
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
|
||||
<authorOrCommitter>false</authorOrCommitter>
|
||||
<wipeOutWorkspace>true</wipeOutWorkspace>
|
||||
<pruneBranches>false</pruneBranches>
|
||||
<remotePoll>false</remotePoll>
|
||||
<gitTool>Default</gitTool>
|
||||
<submoduleCfg class="list"/>
|
||||
<relativeTargetDir/>
|
||||
<reference/>
|
||||
<gitConfigName/>
|
||||
<gitConfigEmail/>
|
||||
<skipTag>false</skipTag>
|
||||
<scmName/>
|
||||
<useShallowClone>false</useShallowClone>
|
||||
<ignoreNotifyCommit>false</ignoreNotifyCommit>
|
||||
<extensions>
|
||||
<hudson.plugins.git.extensions.impl.PathRestriction>
|
||||
<includedRegions>jenkins_jobs
|
||||
tests</includedRegions>
|
||||
</hudson.plugins.git.extensions.impl.PathRestriction>
|
||||
<hudson.plugins.git.extensions.impl.WipeWorkspace/>
|
||||
</extensions>
|
||||
</scm>
|
||||
</project>
|
6
tests/scm/fixtures/git-polling-path-restriction01.yaml
Normal file
6
tests/scm/fixtures/git-polling-path-restriction01.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
scm:
|
||||
- git:
|
||||
url: https://github.com/openstack-infra/jenkins-job-builder.git
|
||||
included-regions:
|
||||
- jenkins_jobs
|
||||
- tests
|
43
tests/scm/fixtures/git-polling-path-restriction02.xml
Normal file
43
tests/scm/fixtures/git-polling-path-restriction02.xml
Normal file
@ -0,0 +1,43 @@
|
||||
<?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://github.com/openstack-infra/jenkins-job-builder.git</url>
|
||||
</hudson.plugins.git.UserRemoteConfig>
|
||||
</userRemoteConfigs>
|
||||
<branches>
|
||||
<hudson.plugins.git.BranchSpec>
|
||||
<name>**</name>
|
||||
</hudson.plugins.git.BranchSpec>
|
||||
</branches>
|
||||
<excludedUsers/>
|
||||
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
|
||||
<disableSubmodules>false</disableSubmodules>
|
||||
<recursiveSubmodules>false</recursiveSubmodules>
|
||||
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
|
||||
<authorOrCommitter>false</authorOrCommitter>
|
||||
<wipeOutWorkspace>true</wipeOutWorkspace>
|
||||
<pruneBranches>false</pruneBranches>
|
||||
<remotePoll>false</remotePoll>
|
||||
<gitTool>Default</gitTool>
|
||||
<submoduleCfg class="list"/>
|
||||
<relativeTargetDir/>
|
||||
<reference/>
|
||||
<gitConfigName/>
|
||||
<gitConfigEmail/>
|
||||
<skipTag>false</skipTag>
|
||||
<scmName/>
|
||||
<useShallowClone>false</useShallowClone>
|
||||
<ignoreNotifyCommit>false</ignoreNotifyCommit>
|
||||
<extensions>
|
||||
<hudson.plugins.git.extensions.impl.PathRestriction>
|
||||
<excludedRegions>doc</excludedRegions>
|
||||
</hudson.plugins.git.extensions.impl.PathRestriction>
|
||||
<hudson.plugins.git.extensions.impl.WipeWorkspace/>
|
||||
</extensions>
|
||||
</scm>
|
||||
</project>
|
5
tests/scm/fixtures/git-polling-path-restriction02.yaml
Normal file
5
tests/scm/fixtures/git-polling-path-restriction02.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
scm:
|
||||
- git:
|
||||
url: https://github.com/openstack-infra/jenkins-job-builder.git
|
||||
excluded-regions:
|
||||
- doc
|
Loading…
Reference in New Issue
Block a user