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.
Community moderators have prevented the ability to post new answers.
Hello Arthur,
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?
regards,
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Nicholas: I believe both answers are "no".
Do you have access to the Bamboo sources?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is perfect. Is this documented anywhere? Can you modify the description as part of the same request? I've tried
http://.../PLAN/branch/branch_name?vcsBranch=branch_name&description=blah
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are any of the other parameters that can be modified in the branch editor GUI modifiable via the REST API?
Or does this all require Bamboo source access?
(Does every on-site Bamboo license holder have source access? If so, I gotta make some calls around the office... )
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
Thanks!
[edit] 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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
did you manage to find a solution for this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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://git@stash.broadinstitute.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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
https://docs.atlassian.com/bamboo/REST/5.5.0/#d2e645
Any one really doing this who can share their techniques?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Erik,
Just to be sure we're standing on the same ground: have you used the vcsBranch parameter in your REST calls? I mean the
?vcsBranch="/refs/heads/myBranch"
part in your PUT request?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For SVN, I just use ?vcsBranch=myBranch It might be similar for GIT. If I put quotes or /branches/ then my URL is messed up for my branch. The plan is already setup to look for branches in .../branches as opposed to .../trunk so it only needs the part after .../branches/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not sure what repo you are using, but for SVN it is a fixed 5 minute interval
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.