exitcode_directive - set runtask exit code based on last or worst YAML outcome

New in version 0.3.18.

This directives takes YAML specified by key result_last or result_worst (keys are mutually exclusive), and generates returncode based on last or worst YAML outcome. If YAML is empty, exitcode is set to SUCCESS.

If task formula contains multiple usages of exitcode directive, worst exitcode is returned by runtask.

Input for directive is supposed to be in a Task result format. The easiest way to create it is to use CheckDetail objects to construct your result (or results), and then generate the YAML output with export_YAML(). Read more in Writing Tasks for Taskotron.

Parameters

parameter required description type default choices

result_last

yes

YAML output, last outcome is used. result_worst cannot be specified together with this one.

str

    result_worst

    yes

    YAML output, worst outcome is used. result_last cannot be specified together with this one.

    str

      Return Values

      int:Returncode based on YAML last or worst outcome. Success is 0, failure is 100.

      Exceptions

      Examples

      Run a check returning multiple results and make runtask fail if any of the results is failed:

      - name: run my check and return YAML
        python:
            file: my_check.py
            callable: run
        export: results
      
      - name: set runtask exit code according to the worst result in YAML
        exitcode:
            result_worst: ${results}
      

      Run a check that returns multiple results and one “overall” result (at the end) which is computed according check’s internal logic. Then make runtask fail if the overall result failed:

      - name: run my check and return YAML
        python:
            file: my_check.py
            callable: run
        export: results
      
      - name: set runtask exit code according to the last (overall) result in YAML
        exitcode:
            result_last: ${results}