1

I'm writing a script to setup a training environment on git and Atlassian Stash (aka Bitbucket Server) using the REST API. I'm creating projects and repositories, populating the repositories...

I'd like to configure the 'Branching Model' for my repositories in that script as well.

I haven't found how to do it via the REST API. What did I miss?

I'm using Atlassian Stash v3.2.4

Thanks in advance.

1615903
  • 32,635
  • 12
  • 70
  • 99
elbeho
  • 71
  • 5

2 Answers2

2

(If it can help someone)

I've been able to setupo the branching model on Stash/Bitbucket servers (Stash v3.11.2, Bitbucket 4.8.3, I haven't tested other versions) :

  $CURL -X PUT -H 'Content-Type: application/json'                                       \
    -d '{"development":{"refId":"refs/heads/develop", "useDefault":false},               \
         "production":{"refId":"refs/heads/master","useDefault":false},                  \
         "types":[                                                                       \
            {"id":"BUGFIX","displayName":"Bugfix","enabled":true,"prefix":"bugfix/"},    \
            {"id":"FEATURE","displayName":"Feature","enabled":true,"prefix":"feature/"}, \
            {"id":"HOTFIX","displayName":"Hotfix","enabled":true,"prefix":"hotfixme/"},  \
            {"id":"RELEASE","displayName":"Release","enabled":true,"prefix":"release/"}  \
           ]}' \
        ${SERVER}/rest/branch-utils/1.0/projects/$key/repos/$slug/branchmodel/configuration

with

$CURL: curl -s -u USER:PASSWORD (and some others options like -k --noproxy...)
$SERVER: the URL to the server
$key: the project key
$slug: the slug (~ the name) of the repository

Hope this helps...

Cheers.

elbeho
  • 71
  • 5
0

Unfortunately there's not a REST API at the moment. It's somerhing we'd like to add in a future version but it's not on the short term roadmap yet.

That said, Stash 3.2 is around 18 months old and I'd highly recommend upgrading to Bitbucket Server 4.x (Stash was renamed at 4.0), there are lots of improvements in the 17 releases (so far) since then.

Rog
  • 4,075
  • 2
  • 24
  • 35
  • 1
    Thanks for the info. Unfortunately, the decision of the upgrade is not in my hands (although I'm pushing for it). – elbeho Jul 08 '16 at 10:59