I have the following workflow that has multiple jobs. I would like to halt the execution of subsequent steps/jobs in previous job.
And I would like to return a success status.
In the following workflow, I would like to halt the execution of the say-hello-second
job in the say-hello
job if the SKIP_JOB
environment variable is set.
I have tried using the circleci-agent step halt
command but it returns a success status and executes the subsequent jobs.
I didn’t find a way to do it, so could you give me the correct command or method?
version: 2.1
jobs:
say-hello:
docker:
- image: cimg/base:current
steps:
- checkout
- run:
name: "halt step"
command: |
if [ -n "$SKIP_JOB" ]; then
echo "halt this step and subsequent steps"
circleci-agent step halt
else
echo "continue to the next step"
fi
- run:
name: "Say Hello"
command: echo "Hello, World!"
say-hello-second:
docker:
- image: cimg/base:current
steps:
- checkout
- run:
name: "Say Hello Second"
command: echo 'Hello, World'
workflows:
say-hello-workflow:
jobs:
- say-hello:
context:
- context-text
- say-hello-second:
requires:
- say-hello