How to do nothing for a branch in a pipeline?
Asked by Eric Anderson:

It is clear enough how to define "default;" pipeline actions that will be applied unless something else is defined for a particular branch.

It would also be clear how to specify to do a particular something for a particular branch.

What should be specified if you want to do nothing for a branch, including not doing the default action? For example, I have tried versions like this (with indentation not easily shown here)...

...  
pipelines:  
default:  
- step:  
script: # Modify the commands below to build your repository.  
...

branches:  
master: # Build was already done when merging into the develop branch.  

But I get the error:  
"\[pipelines \> branches \> master\]. Pipeline is null or empty. Define a pipeline or an import statement."  

It is the same if I try adding statements such as these.  

- step:  
script:  
# Do nothing  

So how does one specify, "I don't want anything done for commits to this branch."?


Answers:
author: Saxea _Flowie_
body: Hi [@Eric Anderson](/t5/user/viewprofilepage/user-id/599292),

I'm not sure if this is possible. I think you would need a step, which could simply do nothing for 'master', e.g., instead of '# Do nothing', you could replace it with - echo "Do nothing".

Another option is to not have a default and specify all branches except 'master'. To avoid duplication, use [YAML anchors](https://support.atlassian.com/bitbucket-cloud/docs/yaml-anchors/), which allow you to define the build once and reuse it.

Also, depending on what you're trying to achieve, you might want to check out [Flowie](https://flowie.app/). It supports [redundant builds prevention](https://flowie.app/docs/en/plugins/merge#redundant-builds-prevention) - which doesn't trigger the pipeline and propagates the status of builds in scenarios when it's possible, e.g., if changes have already been built on another branch.

comments: author: Eric Anderson
body: It won't work well to not have a default option, since the point of having it is to cover all branches, present and future, regardless of name, including branches that haven't been named yet. The default option is definitely needed and appropriate.

Thanks for taking the time to mention [Flowie](https://flowie.app/). I wasn't aware of it. It sounds worth learning more about.

I also had resorted to the (temporary?) fall back option of having the master script due something of little impact (e.g. gcc --version). One certainly can go with a small operation, if it is truly the case that there is no legal way to specify "Don't do anything at all for this branch!"

However, I find it strange that no provision has been made for do-nothing. Start up an instance just so that it can do a bit of unwanted busy-work (because there is no NO-OP option)? Doesn't seem to make sense or be well designed in that regard.

I will wait a bit in the hope that perhaps someone can think of or mention something we cannot think of. (It is such a fundamental concept.) But if no one is able to identify some suitable built-in feature, I will accept your answer as the most helpful answer I've yet seen.

Thanks again and best regards,  
Eric


author: Eric Anderson
body: I want to thank Atlassian Support Engineer Patrik S for suggesting a better approach that avoids unnecessarily starting an instance to run a pipeline that will do "nothing".

The basic idea is that the script: for a branch can specify a condition: that has changesets: with includePaths: that can point to a file. If that file is not modified in a commit to that branch, then the pipeline should not even start for that commit.

I've copied his idea and extended it slightly so that each branch can have its own control file. That allows controlling which branches will execute their script in a pipeline vs. doing truly nothing at all for any commit that did not change the control file for that branch.

![pipelineConditions.png](https://community.atlassian.com/t5/image/serverpage/image-id/301377i0AE9F5F29DA86B8A/image-size/large?v=v2&px=999 "pipelineConditions.png")


author: Eric Anderson
body: **To anyone who may read this**, even though ...

* I appreciate the answer by [Saxea _Flowie](https://community.atlassian.com/t5/user/viewprofilepage/user-id/5230209), and
* I am grateful for her effort and desire to be helpful, and
* I've marked her answer as "accepted", ...

... nevertheless, I do not consider this problem "solved". I would still welcome hearing from anyone who discovers some way to designate in the **bibucket-pipelines.yml** file that "nothing should be done for commits to this branch".

To indicate a "no-op" designation is a fundamental capability. When one is able to default to doing something for any branch general, then it is especially appropriate to be able to also say, "But not for this branch in particular".

If no such capability yet exists, it should be created. Bitbucket?

comments: author: Eric Anderson
body: Please see the **better approach** proposed by Atlassian Support Engineer **Patrik S** that I have provided in my post and Accepted Answer from Jan 18, 2024.


author: Saxea _Flowie_
body: Hi [@Eric Anderson](/t5/user/viewprofilepage/user-id/599292)

We've just released [smart pipelines](https://flowie.app/docs/en/plugins/pipelines) for Flowie, which let you define when you want the pipelines to be triggered based on different conditions, including the source and destination. I think this is a better approach since the pipeline isn't triggered at all---avoiding confusion on 'empty successful' pipelines, decluttering the pipeline view, and saving developers time with no build time wasted as well!


Tags: bitbucket-cloud

cloud