Bamboo variable for second repository
Asked by Dave Brunkow:

Is there a way to use a bamboo variable to reference the second source repository of a project. I can reference the default with ${bamboo.repository.svn.repositoryUrl} but how can I reference a second url without creating some custom/plan variable? There's no way to reference ${bamboo.repository.svn.repositoryUrl.repo2} ????


Answers:
author: Dave Brunkow
body: They're trying to checkout from two different paths in the same repository. I believe the id you're referring to differentiates subversion instances which is not what we have here.

I may have to go with the hack, by putting the repository urls in global variables and reference them in the Source Repository setups and as a global variable also in the scripting piece. It works, jus thought there was a better way.

comments: author: Jan Swaelens
body: You will get different 'IDs' as soon as you define more than one source repo in the bamboo plan. Checking your plan configuration should tell you if this is the case.

Using the plugin you would be able to reference them both using these variables

myCustomLabelForTheFirst.repository.svn.repositoryUrl  
myCustomLabelForTheSecond.repository.svn.repositoryUrl

<br />

<br />


author: PiotrA
body: Hello Dave,

I'm afraid that this particular variable you're after (bamboo.repository.svn.repositoryUrl) is not using the mechanism I was talking about. So as for your question my current answer is "no, you can't reference second SVN repository url".

Just for completeness - the mechanism I was talking about in the other answer injects a repository ID (not an ordering number like 1 - I was wrong on that) between the \*second\* and \*third\* chunk of the variable name. So with the example of ${bamboo.repository.svn.repositoryUrl} I'd expect that one can reference multiple repositories with a syntax like

${bamboo.repository.7435123.svn.repositoryUrl}  
${bamboo.repository.5432125.svn.repositoryUrl}  
${bamboo.repository.1231235.svn.repositoryUrl}

Where the numbers are ID's of plan repositories.

Is there anything else we can help you with?

regards


author: Jan Swaelens
body: Hello,

You could use this plugin to map these repo's to a name of your choice: <https://marketplace.atlassian.com/plugins/be.sofico.bamboo-repopropertymate-plugin>

(disclaimer: I wrote it :-) )


author: Bryan Dyck
body: You can find the magic number(s) for non-default repositories if you look at the Metadata page for a completed build; in the list of variables, you should see entries like this:

repository.$NUMBER.name  
repository.$NUMBER.branch  
etc.

for each non-default repository that's part of the build plan.

comments: author: EddieW
body: @Piotr is right, but I think to @bdyck's poitn, the numbers are the full ID of the repository (i.e. 78586993) and not the ordered number. You can see them listed on the metadata page, just copy the whole variable name string and wrap it in ${}


author: PiotrA
body: Hi Dave,

I recall there is undocumented way to reference non-default source repository in bamboo variables. Although at the moment I can't check how exactly it is done (I can do that on Monday). I vaguelly remember that you need to specify a number in a variable name, so I'd try something like this:

{bamboo.repository.1.svn.repositoryUrl}  
{bamboo.1.repository.svn.repositoryUrl}  
{bamboo.repository.svn.1.repositoryUrl}

...I remember that the number is injected somewhere between two dots in the variablle name.

comments: author: Dave Brunkow
body: Tried those three with leading $, plus ${bamboo.repository.svn.repositoryUrl.1} and they all give me bad substitution.

${bamboo.repository.svn.repositoryUrl.1}: bad substitution


author: PiotrA
body: Well, in that case I'll check the variable syntax for you on Monday, ok? Please ping me here if I forget...


author: Alex Wei (DE)
body: I found the solution at <http://stackoverflow.com/questions/27371629/how-to-tag-a-git-repo-in-a-bamboo-build>.
> ${bamboo.planRepository.repositoryUrl} points to the first repo in your "Source Code Checkout" task. The more specific URLs are referenced via:
>
>     ${bamboo.planRepository.1.repositoryUrl}${bamboo.planRepository.2.repositoryUrl}...
>
> and so on.


Tags: bamboo-administration