diff options
-rw-r--r-- | jenkins_jobs/modules/wrappers.py | 31 | ||||
-rw-r--r-- | tests/cmd/fixtures/unicode001.yaml | 7 | ||||
-rw-r--r-- | tests/jsonparser/fixtures/complete001.json | 42 | ||||
-rw-r--r-- | tests/wrappers/fixtures/pre-scm-buildstep001.plugins_info.yaml | 3 | ||||
-rw-r--r-- | tests/wrappers/fixtures/pre-scm-buildstep001.xml | 30 | ||||
-rw-r--r-- | tests/wrappers/fixtures/pre-scm-buildstep001.yaml | 15 | ||||
-rw-r--r-- | tests/wrappers/fixtures/pre-scm-buildstep002.plugins_info.yaml | 3 | ||||
-rw-r--r-- | tests/wrappers/fixtures/pre-scm-buildstep002.xml | 19 | ||||
-rw-r--r-- | tests/wrappers/fixtures/pre-scm-buildstep002.yaml | 8 | ||||
-rw-r--r-- | tests/yamlparser/fixtures/complete001.yaml | 26 | ||||
-rw-r--r-- | tests/yamlparser/fixtures/include-raw001.yaml | 22 | ||||
-rw-r--r-- | tests/yamlparser/fixtures/include-rawunicode001.yaml | 5 | ||||
-rw-r--r-- | tests/yamlparser/fixtures/include001.yaml | 24 | ||||
-rw-r--r-- | tests/yamlparser/fixtures/unicode001.yaml | 7 |
14 files changed, 163 insertions, 79 deletions
diff --git a/jenkins_jobs/modules/wrappers.py b/jenkins_jobs/modules/wrappers.py index 991ba71c..7e0db489 100644 --- a/jenkins_jobs/modules/wrappers.py +++ b/jenkins_jobs/modules/wrappers.py @@ -1382,33 +1382,34 @@ def pre_scm_buildstep(registry, xml_parent, data): Execute a Build Step before running the SCM 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 :Buildstep: Any acceptable builder, as seen in the example - Example:: + Example: - wrappers: - - pre-scm-buildstep: - - shell: | - #!/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 + .. literalinclude:: + /../../tests/wrappers/fixtures/pre-scm-buildstep001.yaml + :language: yaml """ + # 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, 'org.jenkinsci.plugins.preSCMbuildstep.' 'PreSCMBuildStepsWrapper') 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): 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): diff --git a/tests/cmd/fixtures/unicode001.yaml b/tests/cmd/fixtures/unicode001.yaml index a2bee163..b1e45e35 100644 --- a/tests/cmd/fixtures/unicode001.yaml +++ b/tests/cmd/fixtures/unicode001.yaml @@ -2,9 +2,10 @@ name: unicode-wrapper wrappers: - pre-scm-buildstep: - - shell: | - #!/bin/bash - echo "Unicode! ☃" + buildsteps: + - shell: | + #!/bin/bash + echo "Unicode! ☃" - job: name: test-unicode-wrapper diff --git a/tests/jsonparser/fixtures/complete001.json b/tests/jsonparser/fixtures/complete001.json index 517e1cc2..d6614b66 100644 --- a/tests/jsonparser/fixtures/complete001.json +++ b/tests/jsonparser/fixtures/complete001.json @@ -19,26 +19,28 @@ "name": "pre-scm-shell-ant", "wrappers": [ { - "pre-scm-buildstep": [ - { - "shell": "#!/bin/bash\necho \"Doing somethiung cool\"\n" - }, - { - "shell": "#!/bin/zsh\necho \"Doing somethin cool with zsh\"\n" - }, - { - "ant": { - "targets": "target1 target2", - "ant-name": "Standard Ant" - } - }, - { - "inject": { - "properties-file": "example.prop", - "properties-content": "EXAMPLE=foo-bar" + "pre-scm-buildstep": { + "buildsteps": [ + { + "shell": "#!/bin/bash\necho \"Doing somethiung cool\"\n" + }, + { + "shell": "#!/bin/zsh\necho \"Doing somethin cool with zsh\"\n" + }, + { + "ant": { + "targets": "target1 target2", + "ant-name": "Standard Ant" + } + }, + { + "inject": { + "properties-file": "example.prop", + "properties-content": "EXAMPLE=foo-bar" + } } - } - ] + ] + } } ] } @@ -165,4 +167,4 @@ ] } } -]
\ No newline at end of file +] diff --git a/tests/wrappers/fixtures/pre-scm-buildstep001.plugins_info.yaml b/tests/wrappers/fixtures/pre-scm-buildstep001.plugins_info.yaml new file mode 100644 index 00000000..ba9d7800 --- /dev/null +++ b/tests/wrappers/fixtures/pre-scm-buildstep001.plugins_info.yaml @@ -0,0 +1,3 @@ +- longName: 'Pre SCM BuildStep Plugin' + shortName: 'preSCMbuildstep' + version: "0.3" diff --git a/tests/wrappers/fixtures/pre-scm-buildstep001.xml b/tests/wrappers/fixtures/pre-scm-buildstep001.xml new file mode 100644 index 00000000..e29a60ba --- /dev/null +++ b/tests/wrappers/fixtures/pre-scm-buildstep001.xml @@ -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 "Doing something cool" +</command> + </hudson.tasks.Shell> + <hudson.tasks.Shell> + <command>#!/bin/zsh +echo "Doing something cool with zsh" +</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> diff --git a/tests/wrappers/fixtures/pre-scm-buildstep001.yaml b/tests/wrappers/fixtures/pre-scm-buildstep001.yaml new file mode 100644 index 00000000..b5c17da5 --- /dev/null +++ b/tests/wrappers/fixtures/pre-scm-buildstep001.yaml @@ -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 diff --git a/tests/wrappers/fixtures/pre-scm-buildstep002.plugins_info.yaml b/tests/wrappers/fixtures/pre-scm-buildstep002.plugins_info.yaml new file mode 100644 index 00000000..8a139a77 --- /dev/null +++ b/tests/wrappers/fixtures/pre-scm-buildstep002.plugins_info.yaml @@ -0,0 +1,3 @@ +- longName: 'Pre SCM BuildStep Plugin' + shortName: 'preSCMbuildstep' + version: "0.2" diff --git a/tests/wrappers/fixtures/pre-scm-buildstep002.xml b/tests/wrappers/fixtures/pre-scm-buildstep002.xml new file mode 100644 index 00000000..3f2c11d8 --- /dev/null +++ b/tests/wrappers/fixtures/pre-scm-buildstep002.xml @@ -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 "Doing something cool" +</command> + </hudson.tasks.Shell> + <hudson.tasks.Shell> + <command>#!/bin/zsh +echo "Doing something cool with zsh" +</command> + </hudson.tasks.Shell> + </buildSteps> + </org.jenkinsci.plugins.preSCMbuildstep.PreSCMBuildStepsWrapper> + </buildWrappers> +</project> diff --git a/tests/wrappers/fixtures/pre-scm-buildstep002.yaml b/tests/wrappers/fixtures/pre-scm-buildstep002.yaml new file mode 100644 index 00000000..e9112e29 --- /dev/null +++ b/tests/wrappers/fixtures/pre-scm-buildstep002.yaml @@ -0,0 +1,8 @@ +wrappers: + - pre-scm-buildstep: + - shell: | + #!/bin/bash + echo "Doing something cool" + - shell: | + #!/bin/zsh + echo "Doing something cool with zsh" diff --git a/tests/yamlparser/fixtures/complete001.yaml b/tests/yamlparser/fixtures/complete001.yaml index 519095d6..2a9ce7ec 100644 --- a/tests/yamlparser/fixtures/complete001.yaml +++ b/tests/yamlparser/fixtures/complete001.yaml @@ -11,18 +11,19 @@ name: pre-scm-shell-ant wrappers: - pre-scm-buildstep: - - shell: | - #!/bin/bash - echo "Doing somethiung cool" - - shell: | - #!/bin/zsh - echo "Doing somethin cool with zsh" - - ant: - targets: "target1 target2" - ant-name: "Standard Ant" - - inject: - properties-file: example.prop - properties-content: EXAMPLE=foo-bar + buildsteps: + - shell: | + #!/bin/bash + echo "Doing somethiung cool" + - shell: | + #!/bin/zsh + echo "Doing somethin cool with zsh" + - ant: + targets: "target1 target2" + ant-name: "Standard Ant" + - inject: + properties-file: example.prop + properties-content: EXAMPLE=foo-bar - wrapper: name: copy-files @@ -104,4 +105,3 @@ #!/usr/bin/env python # print("Doing something cool with python") - diff --git a/tests/yamlparser/fixtures/include-raw001.yaml b/tests/yamlparser/fixtures/include-raw001.yaml index bff63ccd..de5e44bb 100644 --- a/tests/yamlparser/fixtures/include-raw001.yaml +++ b/tests/yamlparser/fixtures/include-raw001.yaml @@ -12,16 +12,17 @@ name: pre-scm-shell-ant wrappers: - pre-scm-buildstep: - - shell: - !include-raw: include-raw002-cool.sh - - shell: - !include-raw: include-raw002-cool.zsh - - ant: - targets: "target1 target2" - ant-name: "Standard Ant" - - inject: - properties-file: example.prop - properties-content: EXAMPLE=foo-bar + buildsteps: + - shell: + !include-raw: include-raw002-cool.sh + - shell: + !include-raw: include-raw002-cool.zsh + - ant: + targets: "target1 target2" + ant-name: "Standard Ant" + - inject: + properties-file: example.prop + properties-content: EXAMPLE=foo-bar - wrapper: name: copy-files @@ -42,4 +43,3 @@ - inject: keep-build-variables: true keep-system-variables: true - diff --git a/tests/yamlparser/fixtures/include-rawunicode001.yaml b/tests/yamlparser/fixtures/include-rawunicode001.yaml index e1379dc6..f7472402 100644 --- a/tests/yamlparser/fixtures/include-rawunicode001.yaml +++ b/tests/yamlparser/fixtures/include-rawunicode001.yaml @@ -2,8 +2,9 @@ name: unicode-raw-include-wrapper wrappers: - pre-scm-buildstep: - - shell: - !include-raw: include-rawunicode001-cool.sh + buildsteps: + - shell: + !include-raw: include-rawunicode001-cool.sh - job: name: test-unicode-raw-include-wrapper diff --git a/tests/yamlparser/fixtures/include001.yaml b/tests/yamlparser/fixtures/include001.yaml index 8c7c3cb0..515e11a8 100644 --- a/tests/yamlparser/fixtures/include001.yaml +++ b/tests/yamlparser/fixtures/include001.yaml @@ -12,17 +12,18 @@ name: pre-scm-shell-ant wrappers: - pre-scm-buildstep: - - shell: | - #!/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 + buildsteps: + - shell: | + #!/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 - wrapper: name: copy-files @@ -43,4 +44,3 @@ - inject: keep-build-variables: true keep-system-variables: true - diff --git a/tests/yamlparser/fixtures/unicode001.yaml b/tests/yamlparser/fixtures/unicode001.yaml index a2bee163..b1e45e35 100644 --- a/tests/yamlparser/fixtures/unicode001.yaml +++ b/tests/yamlparser/fixtures/unicode001.yaml @@ -2,9 +2,10 @@ name: unicode-wrapper wrappers: - pre-scm-buildstep: - - shell: | - #!/bin/bash - echo "Unicode! ☃" + buildsteps: + - shell: | + #!/bin/bash + echo "Unicode! ☃" - job: name: test-unicode-wrapper |