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."?
Hi @Eric Anderson,
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, 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. It supports 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.
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. 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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To anyone who may read this, even though ...
... 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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We've just released smart 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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.