Merge "Add support for 'raw' to inject direct xml to job configs."
This commit is contained in:
commit
85634eb37c
@ -214,6 +214,40 @@ the generic macro ``add``. Whenever you forget a parameter from a macro,
|
||||
it will not be expanded and left as is, which will most probably cause havoc in
|
||||
your Jenkins builds.
|
||||
|
||||
.. _raw:
|
||||
|
||||
Raw config
|
||||
^^^^^^^^^^
|
||||
|
||||
It is possible, but not recommended, to use `raw` within a module to
|
||||
inject raw xml into the job configs.
|
||||
|
||||
This is relevant in case there is no apropriate module for a
|
||||
Jenkins plugin or the module does not behave as you expect it to do.
|
||||
|
||||
For example:
|
||||
|
||||
.. literalinclude:: /../../tests/wrappers/fixtures/raw001.yaml
|
||||
|
||||
Is the raw way of adding support for the `xvnc` wrapper.
|
||||
|
||||
To get the apropriate xml to use you would need to create/edit a job
|
||||
in Jenkins and grab the relevant raw xml segment from the
|
||||
`config.xml`.
|
||||
|
||||
The xml string can refer to variables just like anything else and as
|
||||
such can be parameterized like anything else.
|
||||
|
||||
You can use `raw` in most locations, the following example show them
|
||||
with arbitrary xml-data:
|
||||
|
||||
.. literalinclude::
|
||||
/../../tests/yamlparser/fixtures/complete-raw001.yaml
|
||||
|
||||
Note: If you have a need to use `raw` please consider submitting a patch to
|
||||
add or fix the module that will remove your need to use `raw`.
|
||||
|
||||
|
||||
.. _defaults:
|
||||
|
||||
Defaults
|
||||
|
@ -162,3 +162,10 @@ class General(jenkins_jobs.modules.base.Base):
|
||||
lr_adays.text = str(logrotate.get('artifactDaysToKeep', -1))
|
||||
lr_anum = XML.SubElement(lr_xml, 'artifactNumToKeep')
|
||||
lr_anum.text = str(logrotate.get('artifactNumToKeep', -1))
|
||||
|
||||
|
||||
def raw(parser, xml_parent, data):
|
||||
# documented in definition.rst since includes and docs is not working well
|
||||
# For cross cutting method like this
|
||||
root = XML.fromstring(data.get('xml'))
|
||||
xml_parent.append(root)
|
||||
|
@ -67,6 +67,7 @@ jenkins_jobs.builders =
|
||||
multijob=jenkins_jobs.modules.builders:multijob
|
||||
powershell=jenkins_jobs.modules.builders:powershell
|
||||
python=jenkins_jobs.modules.builders:python
|
||||
raw=jenkins_jobs.modules.general:raw
|
||||
sbt=jenkins_jobs.modules.builders:sbt
|
||||
shell=jenkins_jobs.modules.builders:shell
|
||||
shining-panda=jenkins_jobs.modules.builders:shining_panda
|
||||
@ -77,6 +78,7 @@ jenkins_jobs.builders =
|
||||
jenkins_jobs.reporters =
|
||||
email=jenkins_jobs.modules.reporters:email
|
||||
findbugs=jenkins_jobs.modules.reporters:findbugs
|
||||
raw=jenkins_jobs.modules.general:raw
|
||||
jenkins_jobs.properties =
|
||||
authenticated-build=jenkins_jobs.modules.properties:authenticated_build
|
||||
authorization=jenkins_jobs.modules.properties:authorization
|
||||
@ -93,6 +95,7 @@ jenkins_jobs.properties =
|
||||
ownership=jenkins_jobs.modules.properties:ownership
|
||||
priority-sorter=jenkins_jobs.modules.properties:priority_sorter
|
||||
promoted-build=jenkins_jobs.modules.properties:promoted_build
|
||||
raw=jenkins_jobs.modules.general:raw
|
||||
slave-utilization=jenkins_jobs.modules.properties:slave_utilization
|
||||
throttle=jenkins_jobs.modules.properties:throttle
|
||||
zeromq-event=jenkins_jobs.modules.properties:zeromq_event
|
||||
@ -109,6 +112,7 @@ jenkins_jobs.parameters =
|
||||
matrix-combinations=jenkins_jobs.modules.parameters:matrix_combinations_param
|
||||
node=jenkins_jobs.modules.parameters:node_param
|
||||
password=jenkins_jobs.modules.parameters:password_param
|
||||
raw=jenkins_jobs.modules.general:raw
|
||||
run=jenkins_jobs.modules.parameters:run_param
|
||||
string=jenkins_jobs.modules.parameters:string_param
|
||||
svn-tags=jenkins_jobs.modules.parameters:svn_tags_param
|
||||
@ -120,6 +124,7 @@ jenkins_jobs.metadata =
|
||||
string=jenkins_jobs.modules.metadata:string_metadata
|
||||
jenkins_jobs.notifications =
|
||||
http=jenkins_jobs.modules.notifications:http_endpoint
|
||||
raw=jenkins_jobs.modules.general:raw
|
||||
jenkins_jobs.publishers =
|
||||
aggregate-flow-tests=jenkins_jobs.modules.publishers:aggregate_flow_tests
|
||||
aggregate-tests=jenkins_jobs.modules.publishers:aggregate_tests
|
||||
@ -170,6 +175,7 @@ jenkins_jobs.publishers =
|
||||
pmd=jenkins_jobs.modules.publishers:pmd
|
||||
post-tasks=jenkins_jobs.modules.publishers:post_tasks
|
||||
postbuildscript=jenkins_jobs.modules.publishers:postbuildscript
|
||||
raw=jenkins_jobs.modules.general:raw
|
||||
rich-text-publisher=jenkins_jobs.modules.publishers:rich_text_publisher
|
||||
robot=jenkins_jobs.modules.publishers:robot
|
||||
ruby-metrics=jenkins_jobs.modules.publishers:ruby_metrics
|
||||
@ -197,6 +203,7 @@ jenkins_jobs.publishers =
|
||||
jenkins_jobs.scm =
|
||||
git=jenkins_jobs.modules.scm:git
|
||||
hg=jenkins_jobs.modules.scm:hg
|
||||
raw=jenkins_jobs.modules.general:raw
|
||||
repo=jenkins_jobs.modules.scm:repo
|
||||
store=jenkins_jobs.modules.scm:store
|
||||
svn=jenkins_jobs.modules.scm:svn
|
||||
@ -209,6 +216,7 @@ jenkins_jobs.triggers =
|
||||
github-pull-request=jenkins_jobs.modules.triggers:github_pull_request
|
||||
gitlab-merge-request=jenkins_jobs.modules.triggers:gitlab_merge_request
|
||||
pollscm=jenkins_jobs.modules.triggers:pollscm
|
||||
raw=jenkins_jobs.modules.general:raw
|
||||
reverse=jenkins_jobs.modules.triggers:reverse
|
||||
pollurl=jenkins_jobs.modules.triggers:pollurl
|
||||
script=jenkins_jobs.modules.triggers:script
|
||||
@ -241,6 +249,7 @@ jenkins_jobs.wrappers =
|
||||
pathignore=jenkins_jobs.modules.wrappers:pathignore
|
||||
port-allocator=jenkins_jobs.modules.wrappers:port_allocator
|
||||
pre-scm-buildstep=jenkins_jobs.modules.wrappers:pre_scm_buildstep
|
||||
raw=jenkins_jobs.modules.general:raw
|
||||
rbenv=jenkins_jobs.modules.wrappers:rbenv
|
||||
release=jenkins_jobs.modules.wrappers:release
|
||||
rvm-env=jenkins_jobs.modules.wrappers:rvm_env
|
||||
|
16
tests/publishers/fixtures/raw001.xml
Normal file
16
tests/publishers/fixtures/raw001.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<hudson.plugins.build__publisher.BuildPublisher>
|
||||
<serverName>servername</serverName>
|
||||
<publishUnstableBuilds>true</publishUnstableBuilds>
|
||||
<publishFailedBuilds>false</publishFailedBuilds>
|
||||
<logRotator>
|
||||
<daysToKeep>-1</daysToKeep>
|
||||
<numToKeep>100</numToKeep>
|
||||
<artifactDaysToKeep>-1</artifactDaysToKeep>
|
||||
<artifactNumToKeep>100</artifactNumToKeep>
|
||||
</logRotator>
|
||||
</hudson.plugins.build__publisher.BuildPublisher>
|
||||
</publishers>
|
||||
</project>
|
14
tests/publishers/fixtures/raw001.yaml
Normal file
14
tests/publishers/fixtures/raw001.yaml
Normal file
@ -0,0 +1,14 @@
|
||||
publishers:
|
||||
- raw:
|
||||
xml: |
|
||||
<hudson.plugins.build__publisher.BuildPublisher>
|
||||
<serverName>servername</serverName>
|
||||
<publishUnstableBuilds>true</publishUnstableBuilds>
|
||||
<publishFailedBuilds>false</publishFailedBuilds>
|
||||
<logRotator>
|
||||
<daysToKeep>-1</daysToKeep>
|
||||
<numToKeep>100</numToKeep>
|
||||
<artifactDaysToKeep>-1</artifactDaysToKeep>
|
||||
<artifactNumToKeep>100</artifactNumToKeep>
|
||||
</logRotator>
|
||||
</hudson.plugins.build__publisher.BuildPublisher>
|
11
tests/publishers/fixtures/raw002.xml
Normal file
11
tests/publishers/fixtures/raw002.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<FakeServer>
|
||||
<serverName>fake1</serverName>
|
||||
</FakeServer>
|
||||
<FakeServer>
|
||||
<serverName>fake2</serverName>
|
||||
</FakeServer>
|
||||
</publishers>
|
||||
</project>
|
11
tests/publishers/fixtures/raw002.yaml
Normal file
11
tests/publishers/fixtures/raw002.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
publishers:
|
||||
- raw:
|
||||
xml: |
|
||||
<FakeServer>
|
||||
<serverName>fake1</serverName>
|
||||
</FakeServer>
|
||||
- raw:
|
||||
xml: |
|
||||
<FakeServer>
|
||||
<serverName>fake2</serverName>
|
||||
</FakeServer>
|
47
tests/scm/fixtures/raw001.xml
Normal file
47
tests/scm/fixtures/raw001.xml
Normal file
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<scm class="org.jenkinsci.plugins.multiplescms.MultiSCM">
|
||||
<scms>
|
||||
<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://example.com/project.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.WipeWorkspace/>
|
||||
</extensions>
|
||||
</scm>
|
||||
<scm>
|
||||
<scmraw/>
|
||||
</scm>
|
||||
</scms>
|
||||
</scm>
|
||||
</project>
|
8
tests/scm/fixtures/raw001.yaml
Normal file
8
tests/scm/fixtures/raw001.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
scm:
|
||||
- git:
|
||||
url: https://example.com/project.git
|
||||
- raw:
|
||||
xml: |
|
||||
<scm>
|
||||
<scmraw/>
|
||||
</scm>
|
9
tests/wrappers/fixtures/raw001.xml
Normal file
9
tests/wrappers/fixtures/raw001.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<buildWrappers>
|
||||
<hudson.plugins.xvnc.Xvnc>
|
||||
<takeScreenshot>true</takeScreenshot>
|
||||
<useXauthority>false</useXauthority>
|
||||
</hudson.plugins.xvnc.Xvnc>
|
||||
</buildWrappers>
|
||||
</project>
|
7
tests/wrappers/fixtures/raw001.yaml
Normal file
7
tests/wrappers/fixtures/raw001.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
wrappers:
|
||||
- raw:
|
||||
xml: |
|
||||
<hudson.plugins.xvnc.Xvnc>
|
||||
<takeScreenshot>true</takeScreenshot>
|
||||
<useXauthority>false</useXauthority>
|
||||
</hudson.plugins.xvnc.Xvnc>
|
41
tests/yamlparser/fixtures/complete-raw001.xml
Normal file
41
tests/yamlparser/fixtures/complete-raw001.xml
Normal file
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<maven2-moduleset>
|
||||
<actions/>
|
||||
<description><!-- Managed by Jenkins Job Builder --></description>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
||||
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
||||
<concurrentBuild>false</concurrentBuild>
|
||||
<canRoam>true</canRoam>
|
||||
<properties>
|
||||
<propertiesraw/>
|
||||
<hudson.model.ParametersDefinitionProperty>
|
||||
<parameterDefinitions>
|
||||
<parametersraw/>
|
||||
</parameterDefinitions>
|
||||
</hudson.model.ParametersDefinitionProperty>
|
||||
<com.tikal.hudson.plugins.notification.HudsonNotificationProperty>
|
||||
<endpoints>
|
||||
<metadataraw/>
|
||||
</endpoints>
|
||||
</com.tikal.hudson.plugins.notification.HudsonNotificationProperty>
|
||||
</properties>
|
||||
<scm>
|
||||
<scmraw/>
|
||||
</scm>
|
||||
<triggers class="vector">
|
||||
<triggersraw/>
|
||||
</triggers>
|
||||
<reporters>
|
||||
<reportersraw/>
|
||||
</reporters>
|
||||
<builders>
|
||||
<buildersraw/>
|
||||
</builders>
|
||||
<publishers>
|
||||
<publishersraw/>
|
||||
</publishers>
|
||||
<buildWrappers>
|
||||
<wrappersraw/>
|
||||
</buildWrappers>
|
||||
</maven2-moduleset>
|
51
tests/yamlparser/fixtures/complete-raw001.yaml
Normal file
51
tests/yamlparser/fixtures/complete-raw001.yaml
Normal file
@ -0,0 +1,51 @@
|
||||
- project:
|
||||
name: complete002
|
||||
version:
|
||||
- 1.2
|
||||
jobs:
|
||||
- 'complete001_{version}'
|
||||
|
||||
- job-template:
|
||||
name: 'complete001_{version}'
|
||||
project-type: maven
|
||||
scm:
|
||||
- raw:
|
||||
xml: |
|
||||
<!-- <scm> for raw replaces the whole scm section.
|
||||
where as for others the raw part is added to the existing.
|
||||
-->
|
||||
<scm>
|
||||
<scmraw/>
|
||||
</scm>
|
||||
triggers:
|
||||
- raw:
|
||||
xml: |
|
||||
<triggersraw/>
|
||||
wrappers:
|
||||
- raw:
|
||||
xml: |
|
||||
<wrappersraw/>
|
||||
builders:
|
||||
- raw:
|
||||
xml: |
|
||||
<buildersraw/>
|
||||
publishers:
|
||||
- raw:
|
||||
xml: |
|
||||
<publishersraw/>
|
||||
properties:
|
||||
- raw:
|
||||
xml: |
|
||||
<propertiesraw/>
|
||||
parameters:
|
||||
- raw:
|
||||
xml: |
|
||||
<parametersraw/>
|
||||
notifications:
|
||||
- raw:
|
||||
xml: |
|
||||
<metadataraw/>
|
||||
reporters:
|
||||
- raw:
|
||||
xml:
|
||||
<reportersraw/>
|
Loading…
Reference in New Issue
Block a user