Adds support for the Config File Provider Plugin

See https://wiki.jenkins-ci.org/display/JENKINS/Config+File+Provider+Plugin

Change-Id: Ie61bc6c4f934baf7e96bf943efcd66b138ef8edd
This commit is contained in:
aidan.mcginley 2014-09-04 11:04:03 +01:00
parent 5b71cb8ff4
commit 5ed6db1986
8 changed files with 107 additions and 0 deletions

View File

@ -57,6 +57,48 @@ def ci_skip(parser, xml_parent, data):
})
def config_file_provider(parser, xml_parent, data):
"""yaml: config-file-provider
Provide configuration files (i.e., settings.xml for maven etc.)
which will be copied to the job's workspace.
Requires the Jenkins `Config File Provider Plugin.
<https://wiki.jenkins-ci.org/display/JENKINS/Config+File+Provider+Plugin>`_
:arg list files: List of managed config files made up of three\
parameters
:Parameter: * **file-id** (`str`)\
The identifier for the managed config file
:Parameter: * **target** (`str`)\
Define where the file should be created (optional)
:Parameter: * **variable** (`str`)\
Define an environment variable to be used (optional)
Example:
.. literalinclude:: \
/../../tests/wrappers/fixtures/config-file-provider003.yaml
:language: yaml
"""
top = XML.SubElement(xml_parent, 'org.jenkinsci.plugins.configfiles.'
'buildwrapper.ConfigFileBuildWrapper')
xml_files = XML.SubElement(top, 'managedFiles')
files = data.get('files', [])
for file in files:
xml_file = XML.SubElement(xml_files, 'org.jenkinsci.plugins.'
'configfiles.buildwrapper.ManagedFile')
file_id = file.get('file-id')
if file_id is None:
raise JenkinsJobsException("file-id is required for each "
"managed configuration file")
XML.SubElement(xml_file, 'fileId').text = str(file_id)
XML.SubElement(xml_file, 'targetLocation').text = \
file.get('target', '')
XML.SubElement(xml_file, 'variable').text = \
file.get('variable', '')
def logfilesize(parser, xml_parent, data):
"""yaml: logfilesize
Abort the build if its logfile becomes too big.

View File

@ -188,6 +188,7 @@ jenkins_jobs.wrappers =
build-name=jenkins_jobs.modules.wrappers:build_name
build-user-vars=jenkins_jobs.modules.wrappers:build_user_vars
ci-skip=jenkins_jobs.modules.wrappers:ci_skip
config-file-provider=jenkins_jobs.modules.wrappers:config_file_provider
copy-to-slave=jenkins_jobs.modules.wrappers:copy_to_slave
delivery-pipeline=jenkins_jobs.modules.wrappers:delivery_pipeline
env-file=jenkins_jobs.modules.wrappers:env_file

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<buildWrappers>
<org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper>
<managedFiles>
<org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
<fileId>org.jenkinsci.plugins.configfiles.custom.CustomConfig1409250932722</fileId>
<targetLocation>tmp/bar.txt</targetLocation>
<variable>varname</variable>
</org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
</managedFiles>
</org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper>
</buildWrappers>
</project>

View File

@ -0,0 +1,6 @@
wrappers:
- config-file-provider:
files:
- file-id: org.jenkinsci.plugins.configfiles.custom.CustomConfig1409250932722
target: tmp/bar.txt
variable: varname

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<buildWrappers>
<org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper>
<managedFiles>
<org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
<fileId>org.jenkinsci.plugins.configfiles.custom.CustomConfig1234</fileId>
<targetLocation/>
<variable/>
</org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
</managedFiles>
</org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper>
</buildWrappers>
</project>

View File

@ -0,0 +1,4 @@
wrappers:
- config-file-provider:
files:
- file-id: org.jenkinsci.plugins.configfiles.custom.CustomConfig1234

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<buildWrappers>
<org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper>
<managedFiles>
<org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
<fileId>org.jenkinsci.plugins.configfiles.custom.CustomConfig1234</fileId>
<targetLocation/>
<variable/>
</org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
<org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
<fileId>org.jenkinsci.plugins.configfiles.custom.CustomConfig5678</fileId>
<targetLocation>/foo.txt</targetLocation>
<variable>varName</variable>
</org.jenkinsci.plugins.configfiles.buildwrapper.ManagedFile>
</managedFiles>
</org.jenkinsci.plugins.configfiles.buildwrapper.ConfigFileBuildWrapper>
</buildWrappers>
</project>

View File

@ -0,0 +1,7 @@
wrappers:
- config-file-provider:
files:
- file-id: org.jenkinsci.plugins.configfiles.custom.CustomConfig1234
- file-id: org.jenkinsci.plugins.configfiles.custom.CustomConfig5678
target: /foo.txt
variable: varName