Merge "Wrapper pre-scm-buildstep: added support for failOnError parameter"

This commit is contained in:
Jenkins 2017-03-29 09:55:34 +00:00 committed by Gerrit Code Review
commit 4f77324fea
14 changed files with 163 additions and 79 deletions

View File

@ -1402,33 +1402,34 @@ def pre_scm_buildstep(registry, xml_parent, data):
Execute a Build Step before running the SCM Execute a Build Step before running the SCM
Requires the Jenkins :jenkins-wiki:`pre-scm-buildstep <pre-scm-buildstep>`. Requires the Jenkins :jenkins-wiki:`pre-scm-buildstep <pre-scm-buildstep>`.
:arg string failOnError: Specifies if the job should fail on error
(plugin >= 0.3) (default false).
:arg list buildsteps: List of build steps to execute :arg list buildsteps: List of build steps to execute
:Buildstep: Any acceptable builder, as seen in the example :Buildstep: Any acceptable builder, as seen in the example
Example:: Example:
wrappers: .. literalinclude::
- pre-scm-buildstep: /../../tests/wrappers/fixtures/pre-scm-buildstep001.yaml
- shell: | :language: yaml
#!/bin/bash
echo "Doing somethiung cool"
- shell: |
#!/bin/zsh
echo "Doing somethin cool with zsh"
- ant: "target1 target2"
ant-name: "Standard Ant"
- inject:
properties-file: example.prop
properties-content: EXAMPLE=foo-bar
""" """
# Get plugin information to maintain backwards compatibility
info = registry.get_plugin_info('preSCMbuildstep')
version = pkg_resources.parse_version(info.get('version', "0"))
bsp = XML.SubElement(xml_parent, bsp = XML.SubElement(xml_parent,
'org.jenkinsci.plugins.preSCMbuildstep.' 'org.jenkinsci.plugins.preSCMbuildstep.'
'PreSCMBuildStepsWrapper') 'PreSCMBuildStepsWrapper')
bs = XML.SubElement(bsp, 'buildSteps') bs = XML.SubElement(bsp, 'buildSteps')
for step in data: stepList = data if type(data) is list else data.get('buildsteps')
for step in stepList:
for edited_node in create_builders(registry, step): for edited_node in create_builders(registry, step):
bs.append(edited_node) bs.append(edited_node)
if version >= pkg_resources.parse_version("0.3"):
XML.SubElement(bsp, 'failOnError').text = str(data.get(
'failOnError', False)).lower()
def logstash(registry, xml_parent, data): def logstash(registry, xml_parent, data):

View File

@ -2,6 +2,7 @@
name: unicode-wrapper name: unicode-wrapper
wrappers: wrappers:
- pre-scm-buildstep: - pre-scm-buildstep:
buildsteps:
- shell: | - shell: |
#!/bin/bash #!/bin/bash
echo "Unicode! ☃" echo "Unicode! ☃"

View File

@ -19,7 +19,8 @@
"name": "pre-scm-shell-ant", "name": "pre-scm-shell-ant",
"wrappers": [ "wrappers": [
{ {
"pre-scm-buildstep": [ "pre-scm-buildstep": {
"buildsteps": [
{ {
"shell": "#!/bin/bash\necho \"Doing somethiung cool\"\n" "shell": "#!/bin/bash\necho \"Doing somethiung cool\"\n"
}, },
@ -40,6 +41,7 @@
} }
] ]
} }
}
] ]
} }
}, },

View File

@ -0,0 +1,3 @@
- longName: 'Pre SCM BuildStep Plugin'
shortName: 'preSCMbuildstep'
version: "0.3"

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<buildWrappers>
<org.jenkinsci.plugins.preSCMbuildstep.PreSCMBuildStepsWrapper>
<buildSteps>
<hudson.tasks.Shell>
<command>#!/bin/bash
echo &quot;Doing something cool&quot;
</command>
</hudson.tasks.Shell>
<hudson.tasks.Shell>
<command>#!/bin/zsh
echo &quot;Doing something cool with zsh&quot;
</command>
</hudson.tasks.Shell>
<hudson.tasks.Ant>
<targets>target1 target2</targets>
<antName>default</antName>
</hudson.tasks.Ant>
<EnvInjectBuilder>
<info>
<propertiesFilePath>example.prop</propertiesFilePath>
<propertiesContent>EXAMPLE=foo-bar</propertiesContent>
</info>
</EnvInjectBuilder>
</buildSteps>
<failOnError>true</failOnError>
</org.jenkinsci.plugins.preSCMbuildstep.PreSCMBuildStepsWrapper>
</buildWrappers>
</project>

View File

@ -0,0 +1,15 @@
wrappers:
- pre-scm-buildstep:
failOnError: true
buildsteps:
- shell: |
#!/bin/bash
echo "Doing something cool"
- shell: |
#!/bin/zsh
echo "Doing something cool with zsh"
- ant: "target1 target2"
ant-name: "Standard Ant"
- inject:
properties-file: example.prop
properties-content: EXAMPLE=foo-bar

View File

@ -0,0 +1,3 @@
- longName: 'Pre SCM BuildStep Plugin'
shortName: 'preSCMbuildstep'
version: "0.2"

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<buildWrappers>
<org.jenkinsci.plugins.preSCMbuildstep.PreSCMBuildStepsWrapper>
<buildSteps>
<hudson.tasks.Shell>
<command>#!/bin/bash
echo &quot;Doing something cool&quot;
</command>
</hudson.tasks.Shell>
<hudson.tasks.Shell>
<command>#!/bin/zsh
echo &quot;Doing something cool with zsh&quot;
</command>
</hudson.tasks.Shell>
</buildSteps>
</org.jenkinsci.plugins.preSCMbuildstep.PreSCMBuildStepsWrapper>
</buildWrappers>
</project>

View File

@ -0,0 +1,8 @@
wrappers:
- pre-scm-buildstep:
- shell: |
#!/bin/bash
echo "Doing something cool"
- shell: |
#!/bin/zsh
echo "Doing something cool with zsh"

View File

@ -11,6 +11,7 @@
name: pre-scm-shell-ant name: pre-scm-shell-ant
wrappers: wrappers:
- pre-scm-buildstep: - pre-scm-buildstep:
buildsteps:
- shell: | - shell: |
#!/bin/bash #!/bin/bash
echo "Doing somethiung cool" echo "Doing somethiung cool"
@ -104,4 +105,3 @@
#!/usr/bin/env python #!/usr/bin/env python
# #
print("Doing something cool with python") print("Doing something cool with python")

View File

@ -12,6 +12,7 @@
name: pre-scm-shell-ant name: pre-scm-shell-ant
wrappers: wrappers:
- pre-scm-buildstep: - pre-scm-buildstep:
buildsteps:
- shell: - shell:
!include-raw: include-raw002-cool.sh !include-raw: include-raw002-cool.sh
- shell: - shell:
@ -42,4 +43,3 @@
- inject: - inject:
keep-build-variables: true keep-build-variables: true
keep-system-variables: true keep-system-variables: true

View File

@ -2,6 +2,7 @@
name: unicode-raw-include-wrapper name: unicode-raw-include-wrapper
wrappers: wrappers:
- pre-scm-buildstep: - pre-scm-buildstep:
buildsteps:
- shell: - shell:
!include-raw: include-rawunicode001-cool.sh !include-raw: include-rawunicode001-cool.sh

View File

@ -12,6 +12,7 @@
name: pre-scm-shell-ant name: pre-scm-shell-ant
wrappers: wrappers:
- pre-scm-buildstep: - pre-scm-buildstep:
buildsteps:
- shell: | - shell: |
#!/bin/bash #!/bin/bash
echo "Doing somethiung cool" echo "Doing somethiung cool"
@ -43,4 +44,3 @@
- inject: - inject:
keep-build-variables: true keep-build-variables: true
keep-system-variables: true keep-system-variables: true

View File

@ -2,6 +2,7 @@
name: unicode-wrapper name: unicode-wrapper
wrappers: wrappers:
- pre-scm-buildstep: - pre-scm-buildstep:
buildsteps:
- shell: | - shell: |
#!/bin/bash #!/bin/bash
echo "Unicode! ☃" echo "Unicode! ☃"