On this page
Summary
The addRepository action can be used to add repositories to a plan. However, you must know the parameter fields that each repository uses and needs. Normally, the repository provider doesn't document this. However, they can be discovered. We have documented some examples already - see Examples for AddRepository Action. If the repository type you want is not already documented or you are getting errors adding a repository (perhaps because the example is out of date), then you need to discover the fields needed. There are 2 ways to discover these fields.
- Using exportPlan on an existing plan that has been created manually through the UI with the repository you want to create through automation.
- Using browser tools to discover fields from the UI similar to how this is done in How to determine fields for addTask
We will just document the first option here.
Steps using exportPlan
Examples
There are 3 ways to use the addRepository action:
- Add a repository directly to a plan - see the discussion below and make sure you specify the plan parameter.
- Add a linked (global) repository - see the discussion below and do not specify the plan parameter.
- Associating a linked repository to a plan - see How to add a linked repository to a plan.
Best Practice is to Use Linked Repositories
We strongly recommend using globally configured linked repositories. This make plan configuration easier and more maintainable. Adopt a good naming convention to make configuration easier. Linked repositories are easily created with addRepository. Internally, we script defining (and updating) all our repositories to ensure consistency and make updates easier. Linked repositories are easily referenced in build plans including simple name references in plan scripting with the addRepository action for a plan.
Best Practice is to Use Shared Credentials
More recent versions of Bamboo support shared credentials for Git, Mercurial, and Bitbucket Cloud repositories. This centralizes password or SSH maintenance and makes adding repositories and add repository scripting significantly easier by avoiding having confidential information in your scripts. CLI release 7.1 includes support for managing credentials and for referencing them on addRepository. Note Bitbucket Server authorization is done via application links, so it doesn't need specific shared credentials.
The addRepository action can be used to add source repositories to a plan or as a linked repository. However, you must know the parameter fields that each repository uses and needs. The following gives some examples. If the repository you want is not one of the examples, the parameters can be discovered similar to the following: How to determine fields for addRepository. If you get errors, you will need to debug the field problem by using the url used by the CLI tool in a browser so the errors are more prevalent. Run the action with --verbose and look for url that is being used and failing. This is the best that can be done until Bamboo provides proper REST APIs to help with this scenario.
Your repository not listed yet?