Stop build with Success/Failure at any point in the build life-cycle

Given that CircleCI does not provide us with configurations options, lets say I wish to run some specific commands based on some parameters sent to the build via API. I would like to be able to stop the build once that is complete - the build result reflecting the exit code of that command. This way, I do not have to IF-GATE the rest of my circle.yml to avoid those steps when this parameter is sent.

Right now, we can fail the build at that point but we cannot post a success from that build and still avoid successive steps.

4 Likes

this is something i am looking for. How can I achieve this?

...
    steps:
      - checkout
      - run:
          name: Skip following steps if check is passed
          command: |
            if ! git diff --name-only origin/master | grep specific_assets &> /dev/null; then
              # FINISH JOB HERE
            fi
...

To skip the rest of the steps in this job and mark job as successfull:
circleci step halt

To skip the rest of the steps in this job and mark job as failled:
exit 1 good enough?

1 Like