Merge "deprecate postbuildscript onsuccess and onfailure parameter names"

This commit is contained in:
Jenkins 2014-12-16 15:50:24 +00:00 committed by Gerrit Code Review
commit 1d3af0f3ce
3 changed files with 26 additions and 13 deletions

View File

@ -2425,18 +2425,20 @@ def postbuildscript(parser, xml_parent, data):
:arg list groovy-script: Paths to Groovy scripts :arg list groovy-script: Paths to Groovy scripts
:arg list groovy: Inline Groovy :arg list groovy: Inline Groovy
:arg list builders: Any supported builders, see :doc:`builders`. :arg list builders: Any supported builders, see :doc:`builders`.
:arg bool onsuccess: Scripts and builders are run only if the build succeed :arg bool onsuccess: Deprecated, replaced with script-only-if-succeeded
(default True) :arg bool script-only-if-succeeded: Scripts and builders are run only if
:arg bool onfailure: Scripts and builders are run only if the build fail the build succeeded (default True)
(default False) :arg bool onfailure: Deprecated, replaced with script-only-if-failed
:arg bool script-only-if-failed: Scripts and builders are run only if the
build failed (default False)
:arg str execute-on: For matrix projects, scripts can be run after each :arg str execute-on: For matrix projects, scripts can be run after each
axis is built (`axes`), after all axis of the matrix axis is built (`axes`), after all axis of the matrix
are built (`matrix`) or after each axis AND the matrix are built (`matrix`) or after each axis AND the matrix
are built (`both`). are built (`both`).
The `onsuccess` and `onfailure` options are confusing. If you want The `script-only-if-succeeded` and `bool script-only-if-failed` options are
the post build to always run regardless of the build status, you confusing. If you want the post build to always run regardless of the build
should set them both to `false`. status, you should set them both to `false`.
Example: Example:
@ -2503,10 +2505,21 @@ postbuildscript003.yaml
# When to run the build? Note the plugin let one specify both options # When to run the build? Note the plugin let one specify both options
# although they are antinomic # although they are antinomic
# onsuccess and onfailure parameters are deprecated, this is to keep
# backwards compatability
success_xml = XML.SubElement(pbs_xml, 'scriptOnlyIfSuccess') success_xml = XML.SubElement(pbs_xml, 'scriptOnlyIfSuccess')
success_xml.text = str(data.get('onsuccess', True)).lower() if 'script-only-if-succeeded' in data:
success_xml.text = str(data.get('script-only-if-succeeded',
True)).lower()
else:
success_xml.text = str(data.get('onsuccess', True)).lower()
failure_xml = XML.SubElement(pbs_xml, 'scriptOnlyIfFailure') failure_xml = XML.SubElement(pbs_xml, 'scriptOnlyIfFailure')
failure_xml.text = str(data.get('onfailure', False)).lower() if 'script-only-if-failed' in data:
failure_xml.text = str(data.get('script-only-if-failed',
False)).lower()
else:
failure_xml.text = str(data.get('onfailure', False)).lower()
# TODO: we may want to avoid setting "execute-on" on non-matrix jobs, # TODO: we may want to avoid setting "execute-on" on non-matrix jobs,
# either by skipping this part or by raising an error to let the user know # either by skipping this part or by raising an error to let the user know

View File

@ -9,5 +9,5 @@ publishers:
groovy: groovy:
- "/** This is some inlined groovy */" - "/** This is some inlined groovy */"
- "/** Some more inlined groovy */" - "/** Some more inlined groovy */"
onsuccess: False script-only-if-succeeded: False
onfailure: True script-only-if-failed: True

View File

@ -12,5 +12,5 @@ publishers:
groovy-script: groovy-script:
- '/tmp/one.groovy' - '/tmp/one.groovy'
- '/tmp/two.groovy' - '/tmp/two.groovy'
onsuccess: False script-only-if-succeeded: False
onfailure: True script-only-if-failed: True