Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Stop pipeline without failure (GitOps "empty-commit" commands)

Charles Paul
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 18, 2025

I am implementing a GitOps solution using Bitbucket pipelines but am having difficulties incorporating GitOps commands using empty commits. 

I set up a `default` pipeline that inspects the commit message to execute the GitOps action in order to deploy to specific environments.  There is also a pipeline to handle pull requests to `main`.  The issue is that the default pipeline always runs, but there is no graceful way to prematurely stop this pipeline if a command is not issued.  Take this (paraphrased) example pipeline:


pipelines:
default:
- step:
name: Check GitOps Command
runs-on:
- self.hosted
script:
- export COMMIT_MESSAGE=$(git log --format=%B -n 1 $BITBUCKET_COMMIT)
- if [[ "${COMMIT_MESSAGE,,}" != *"[deploy]"* ]]; then
- echo "STOP_PIPELINE=true" >> $BITBUCKET_PIPELINES_VARIABLES_PATH
- exit 0
- fi
- export ENV=`echo $COMMIT_MESSAGE | cut -d ']' -f2 | xargs`
- echo "ENV=$ENV" >> $BITBUCKET_PIPELINES_VARIABLES_PATH
output-variables:
- ENV
- STOP_PIPELINE
- step:
name: 'Run Deployment'
trigger: manual # The trigger will always activate, unless exit 1 in previous step
script:
- if [ $STOP_PIPELINE ]; then exit 0; fi
- ./deploy_command $ENV
pull-requests:
'**':
- step:
name: 'Check branch and run tests'
script:
- if [ "${BITBUCKET_PR_DESTINATION_BRANCH}" != "main" ]; then printf 'target branch not main, skipping test'; exit; fi
- run_test_command


The `default` pipeline will run on every commit regardless if there is a gitops command in the commit message.  A variable can be set in to prematurely end subsequent steps, but it will not prevent a manual trigger from being activated.

Is there a way to gracefully stop a pipeline without creating a failure event and subsequent notifications?  That or a way to run pipelines for empty commits outside of "default"?

1 answer

0 votes
Aron Gombas
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 19, 2025

I think we were in a slightly similar situation years ago.

As far as I remember, Pipelines decides the "success or failure" state based on the OS level exit code of the last command. And you can maybe do tricks like piping the command output to an empty sink to "swallow" the exit code of the command...

Just a hint.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events