Skip to content

"Switch-case" statement (or smoother patterns for conditionally running steps) #7843

Answered by suhlig
tomasgareau asked this question in Ideas
Discussion options

You must be logged in to vote

You could wrap the command in a script that writes the exit code to a file (and make the script itself exit 0).
The file would be in one of the task's outputs. The next task(s) read that file and either do nothing (the file contents are not for them), or do whatever needs to be done.

jobs:
  - name: deploy-terraform
    plan:
    - task: terraform-plan
      config:
        platform: linux
        image_resource:
          type: registry-image
          source: { repository: busybox }
        outputs: [ name: terraform-result ]
        run:
          path: sh
          args:
          - -c # note the absence of -e
          - |
            (exit 1) # simulate a command that produces exit …

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@tomasgareau
Comment options

Comment options

You must be logged in to vote
1 reply
@tomasgareau
Comment options

Answer selected by tomasgareau
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
4 participants