Forums

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

Avoid running pipeline when creating new branch from master

leech
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!
September 5, 2018

We create a new release branch from master every new main release of our project. And we have pipelines applied to this new branch `release/*` so that all the new PRs to this new branch gets executed with this pipeline.

But the problem is that every time I create a new release branch from master the pipeline is executed, wasting usage from my allocated pipelines time.

Is there a way to avoid that? Or probably know if this new branch was created from master and no new commits so that I can skip all the following commands?

 

1 answer

2 votes
Steven Vaccarella
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 17, 2018

Hi Leandro,

Try using the following git command. It shows the commits that are on the current branch but not on master. If it doesn't output anything then you can exit early.

git log master..

eg:

script:
- if [ -z "`git log master..`" ]; then exit 0; fi

Cheers,
Steven

Deleted user September 18, 2018

Awesome! 

Thank you!

Graham Gatus
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 18, 2018

If you tag each release, you can also use 'git describe' to check if there exists a tag pointing to the commit thats at the head of the newly created release branch.

If a tag exists, skip running tests and deployments (since its most likely a new release branch thats been pushed).

If no tag exists, then you have new commits on that branch, and you probably want to go ahead and run tests, deploy etc.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events