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
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!
On 31 May, a GDPR-related change went live in the Bitbucket Cloud API that resulted in users not being able to create or edit Bitbucket Cloud Linked repositories in Bamboo. This API update removed t...
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