Maybe I missed it, but is there a Bamboo API to create branches? There seems to be ones to GET branches, but I'd like to create new branches. The Bamboo polling mechanism works, but polling is much slower than a push mechanism.
I believe there is an undocumented API for creating arbitrary branch-plan since Bamboo 5.0. Usage gist:
curl -X PUT --user admin:admin http://localhost:8085/rest/api/latest/plan/PROJ-PLAN/branch/yourNewBranchName?vcsBranch="/refs/heads/myBranch"
(the "yourNewBranchName" is the name of the plan-branch visible in Bamboo UI, and the "vcsBranch" parameter defines which branch should be used when polling your source code repository)
Does this help you?
That's exactly what I wanted, thank you!
Now I'm wondering, is there a way to modify the task that branches run vs master? For example, we use Maven and our master build does a mvn clean deploy, whereas the branch I'd like to do a mvn clean verify (not deploy). Perhaps this is worth a separate question.
We're a Bamboo OnDemand customer.
I tried to use the undocumented API (using the exact curl statement shown in the example) but got a "411 - Length required" response. Any workarounds for this? It would be great to be able to automate branch creation in our Bamboo plans.
 Answering my own question:
Sounds like it is specific to nginx (which is what Atlassian uses for gw to OnDemand), see http://serverfault.com/questions/164220/is-there-a-way-to-avoid-nginx-411-content-length-required-errors
Workaround is to add -H "Content-Length: 0" to your curl command. I did this and it worked great!
I know I'm late to the party in asking this, but is there a way to use this REST API to enable the branch plan and set its trigger type to manual?
I can use the shared REST API syntax to create a branch plan, but I'd like to also make sure I can enable the plan and change its trigger type to manual with this same call, if possible. Some background on this: I have dozens and dozens of develop branches that I have to manually create plan branches for, which are set up with a manual trigger type to work with Bob Swift automation. I'd like to automate creating all those release branch plans.
Was away so have not responded.
Yes, I have the vcsBranch option in the REST call.
My problem turned out to be a BASH scripting error - Since I was using Basic authentication, my url looked like
curl --verbose -X PUT --user xxx:pwd http://host:8085/rest/api/latest/plan/E2P-SB/branch/release-1.1?os_authType=basic&vcsBranch=/refs/heads/release/1.1
And the &vcsBranch was being treated as a background job. It needed to be escaped with a "\"
So now I am one step closer, now I get Bamboo complaining that the branch can not be found:
Eriks Test Project - Sandbox - Branch - release-1.1 › E2P-SB1-1 : Errors getting changes for E2P-SB1-1 (com.atlassian.bamboo.repository.RepositoryException : java.lang.RuntimeException: com.atlassian.bamboo.repository.InvalidRepositoryException: Cannot determine head revision of 'ssh://firstname.lastname@example.org:7999/et/sandbox.git' on branch '/refs/heads/release/1.1'. Branch has probably been removed.) (17 Jun 2014, 4:42:40 PM)
In the branch's Source Repository tab, the branch name was listed as /refs/heads/release/1.1.
I then checked out Branch plans that were automatically created and saw that their branches names were simply "release/1.1"
So, in summary, for GIT, the correct value for the vcsBranch parameter should not include /ref/heads, but the simple branch name.
I would have saved a lot of time, if the REST documentation was fleshed out.
When I try this with a GIT repo, it does create a new branch plan but it does not overide the repository setting so it does not use the branch for the build.
There is "some" documentation for the 5.5 API -- but it does not say much.
Any one really doing this who can share their techniques?
Interested in learning more about Jira Work Management? Have questions you want to get answered? Join us for our upcoming live demo where we’ll take you through the essentials of Jira Work Manageme...
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