Fix support for obsolete format of pre-scm-buildstep

'pre-scm-buildstep' wrapper has two modes:
1. Older: no 'buildsteps' element is specified. Build steps is a list under
   wrapper name. For example:

    - pre-scm-buildstep:
      - shell: echo hello
      - shell: echo bye

2. Newer: build steps specified inside 'buildsteps' mapping element:

    - pre-scm-buildsteps:
        buildsteps:
        - shell: echo hello
        - shell: echo bye

But, when 'preSCMbuildstep' plugin version is equal or higher 0.3, and first
mode is used, it fails.

Fix that.

Change-Id: I010d9f6c5e06ccd8c2723026aae2c60f79917ff4
This commit is contained in:
Vsevolod Fedorov 2023-12-14 11:58:31 +03:00
parent fa57eff9f2
commit 70436726ad
4 changed files with 31 additions and 1 deletions

View File

@ -1833,7 +1833,7 @@ def pre_scm_buildstep(registry, xml_parent, data):
for step in stepList:
for edited_node in create_builders(registry, step):
bs.append(edited_node)
if version >= pkg_resources.parse_version("0.3"):
if version >= pkg_resources.parse_version("0.3") and not isinstance(data, list):
mapping = [("failOnError", "failOnError", False)]
helpers.convert_mapping_to_xml(bsp, data, mapping, fail_required=True)

View File

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

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"