pythonconcourseconcourse-pipeline

Concourse Pipeline: How to have an Embedded Script Fail the Pipeline


When I run a Concourse pipeline with a nested Python script inside of the run param like so:

- task: some-task
    params:
      ...
    config:
      platform: linux
      ...
      run:
        path: bash
        args:
        - "-c"
        - |

          python my_failing_python_code.py

When the python script fails, throwing an exit 1, the error does not seem to bubble up to the pipeline like I would expect. Overall the pipeline ends "successfully".

How should I set up my pipeline to read the exit status of a script run within the pipeline?

Thanks


Solution

  • If that is the whole content of the script, then you can replace it with

    run:
            path: python
            args:
            - my_failing_python_code.py
    

    See https://concourse-ci.org/hello-world-example.html

    if the shell script does also other things, you are missing a set -e, to tell the shell to report an error:

        run:
            path: bash
            args:
            - "-c"
            - |
              set -e
              python my_failing_python_code.py
    

    See https://concourse-ci.org/tasks.html