Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Does the repository name relate to a variable? #3199

nancylt723 ·
I need to pass the name of the repositories that I check out in a configuration as variables to a script that I call in a later step. Doe the repository names relate to variable names, and if so, what are they called?
  • replies 11
  • views 6790
  • stars 0
robinshen ADMIN ·
Please define a variable with below value, then you can use that variable to get the repository name.
${groovy:
for (repo in configuration.referencedRepositories)
return repo.name;
return "";
}
nancylt723 ·
I'm sorry, but I don't work with variables that much. My repo name is FMHelpDocs and the configuration name is root/ZZZTest/Test_repo_name. This is what I tried for my variable repo_name:

${groovy: for (FMHelpDocs in root/ZZZTest/Test_repo_name.referencedRepositories) return repo.name; return ""; }

This does not work. Can you tell me what I am doing wrong?
robinshen ADMIN ·
If you already know the repository name "FMHelpDocs", why bother needing a variable to get that repository name?
nancylt723 ·
Because I wish to make this a step that I can call in any configuration without changing it.
robinshen ADMIN ·
OK I get it. To reference a configuration by path, call system.configurationManager.get("path/to/configuration"), so the script can be written as below if you want to refer to a different configuration:
${groovy:
for (repo in system.configurationManager.get("root/ZZZTest/Test_repo_name").referencedRepositories)
return repo.name;
return "";
}
nancylt723 ·
And what if more than one repository is being checked out?
robinshen ADMIN ·
Then you can loop through the referencedRepositories to get name of every checked out repository, and concatenating them as a string separated by for instance comma
nancylt723 ·
The groovy solution that you sent worked great. Now I need to know if there is a way that I can save the PULL URL for the repo to a variable.
robinshen ADMIN ·
Do you mean the fetch url of a git repository? If yes, use below script to do it:
vars.get("some var").setValue(repositories.get("your git repo").fetchUrl);
nancylt723 ·
Well, we use Mercurial, so an hg repo. How would I construct this if I don't know the name of the repo?
robinshen ADMIN ·
Below script will do the job:
${groovy:
for (repo in system.configurationManager.get("root/ZZZTest/Test_repo_name").referencedRepositories)
return repo.pullUrl;
return "";
}