Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Is it possible for Bamboo to create a branch when a build fails? Edited

Hi, I use

- Bamboo 6.0 (hosted on a 64-bit Windows 10 machine)

- Git 2.13

- SourceTree 2 (I use GitFlow plugin)

- Git remote repository: Bitbucket Cloud and GitLab with Git LFS 2

- Visual Studio 2017 for C++ Win32 applications


This is a scenario that I want;


1. Bamboo checks the Git remote repository and pulls the latest commit.

(Most of the commits are pushed to the develop branch.)


2. If a build fails, a branch is created from the latest commit and it is pushed to the remote repository.

For instance, Bamboo detects a failed build after polling the commits from GitLab or Bitbucket. Then, Bamboo creates "BAM-PROJKEY-101" branch and pushes it to the remote repository so the developer can pull the branch to solve the problem.


3. The developer commits codes to the newly created branch and merges it back to the develop branch.




In short, Is this branch creating feature possible with Bamboo 6 when using remote repositories such as Bitbucket Cloud / GitLab / SVN / Perforce?


-Best regards, Young Kwang, Kim


1 answer

1 accepted

0 votes
Answer accepted

Hi Young,

One way to go about this would be to use How to commit to a Git repo during a build or How to push to repository under SSH protocol using Script task to create the branch as part of a script task the same way you push changes you should be able to push a new branch, however, if you don't know yet whether it's going to fail you'll probably have to create the script task as a final task
so that task will run no matter what.

In that regard you will also have to create some sort of condition, like a semaphore, that will tell the script GO or NO-GO based on that condition and before the build is actually finished.

There may also be another way to accomplish this, but rather complex..

You're using Bamboo 6 and can make use of a dark feature called "Final Stages".. it's similar to the Final Task, but for a Stage instead... it will run no matter what - the interesting part with Final Stages is that you could call the following REST endpoint using a Script task http://localhost:8085/rest/api/latest/result/PROJ-PLAN-<BUILDNUMBER>?expand=stages.stage to capture the state of each stage that finished before the "Final Stage"..

 If everything is successful don't trigger the script that will create and push the branch to the repository, if any of the stages failed (meaning a job failed, meaning the build will fail), then kick off the script to create the branch
RE <BUILDNUMBER> and you can use the Bamboo variables at runtime to get the number of the current running build.

It's not as simple as using Final Tasks but it's another possibility.

Hopefully that points you in the right direction!



Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bamboo

Bamboo 101 Video

G’day Community! As we gear up to introduce Bamboo Data Center to the world, we wanted to make sure that we shared a bit more about Bamboo, the product. Our team has put together an overview video ...

227 views 4 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you