Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Does a programmatic method exist to create Linked Repositories?

I'm leveraging all of the goodness of Spec Plans, but it depends heavily on an existing Linked Repository.

Here is what I have so far:

Step 1 - Use the Bitbucket API to setup a code repository [scripted]

Step 2 - Log into Bitbucket, create 'Linked Repository' (LR) to new code repo [manual]

Step 3 - Execute java Spec Plan to create a Bamboo Build Plan (linked to the LR) [scripted]

You can see the significant interrupt in my attempt to create a push-button setup.


The closest I find is Bob Swift's CLI tool. While neat, I don't have local Bamboo Admin access.

All actions must be via API or remotely.

Thanks in advance!

2 answers

2 votes

Try Bamboo Specs for linked repositories management

BambooServer bambooServer = new BambooServer("http://localhost:6990/bamboo");
final GitRepository gitRepository = new GitRepository()
.name("Test repository")
.authentication(new UserPasswordAuthentication("user")
.changeDetection(new VcsChangeDetection());

Thanks Alexey, but a recent article indicates that global linked repository are preferred and that manually configured repository are to be deprecated. So I was hoping to adopt the preferred method. 

Article -

This code creates global linked repository

Hi @Alexey Chystoprudov 

Will above code create linked repository and how to enable scan for bamboo specs in this code. I want to create linked repository with scan bamboo specs in bitbucket. So can I do it in java.

@Hema , it will create repository. Then you need to enable Specs detection

curl -u admin:admin -X PUT http://localhost:8085/rest/api/latest/repository/123/enableCi

Then you also need to grant permissions to particular projects or grant access for this repo to all your projects

Unfortunately there's no Rest API to get repo id by its name so you need to get it manually through UI. You can watch and vote for to address it.

Hi @Alexey Chystoprudov ,

Thanks for response.

I created plan using bitbucket spec repository but when I saw bamboo plan, it is not allowing to edit on bamboo. Showing message like edit this plan using bitbucket spec repository. So can you please help me if I want to create plan using butbucket repo as well modify changes using bamboo UI.

Also how to enable scan for bamboo spec using bamboo java spec

Once plan is managed by repository you can't edit it by UI. If you need to turn it off - publish it from local environment by command executed at bamboo-specs folder of your repo.

mvn -Ppublish-specs 

It's not possible to enable Bamboo Specs property of repository from Bamboo Specs

Like Jeyanthan I likes this

Hi @Alexey Chystoprudov 

I have created bamboo spec stored in bitbucket repository and created lonked repository in bamboo, enabled scan for spec. But when bamboo scan for spec, it is asking for ssh private and public key for plan repository stored in bitbucket RSS. If I mentioned public and private key then it publish plan repository in plan. So if any other user change in spec then will it work for him.

What exactly consists in public and private key ie is it specific to user

0 votes
Jeyanthan I Atlassian Team Apr 03, 2018

Hi Chad,

Bamboo does not provide the REST end point to create a new linked repository (yet as of Bamboo 6.4.1). I found an open feature request for this - BAM-18453

I recommend you vote for it and comment to get it prioritised.

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events