Accessing another project's parameters

I'm dealing with one project Parent that has a bunch of projects related to a specific branch of our code. Let's say Parent has two children, Subproject1 and Subproject2. Subproject2 has a child C1. Can C1 access Subproject1's parameters? I only own Subproject2, so I can't modify Subproject1 or Parent.

0
5 comments

Hi Chris,

From the sounds of it, the best way would probably be to set up a Snapshot Dependency making Subproject2/C1 dependent on a Build Configuration from Subproject1. After you have this Snapshot Dependency in place, you can access the parameters belonging to Subproject1 by using the format of:

dep.<build configuration id>.<parameter name> 

Here is some information on Snapshot Dependencies: https://www.jetbrains.com/help/teamcity/dependent-build.html#DependentBuild-SnapshotDependency

Here is some information on dependent parameters: https://www.jetbrains.com/help/teamcity/predefined-build-parameters.html#Dependencies-Properties

If you were able to work with the owners of Parent or Subproject, you could set the parameter at the Parent level. In this way, both Subproject1 and Subproject2 would be able to access the same parameter without requiring any dependencies. 

 

0

Thanks Eric,

Can I set up a separate build just to get that parameter value without needing a teamcity agent to run something? I'm not sure linking it to an actually build would work. I don't want to need to build something, and the value changes, so I need to be able to get the up to date value.

Putting it in Parent wouldn't work either. It already exists in parent, but Subproject1 overrides that parameter with a different value.

0

The only way to use a parameter from another build configuration would be to establish some sort of dependency on another build. However, setting up a separate build, in this case, might not be the best approach. Could you briefly describe your workflow on Subproject2/C1 and what you're trying to accomplish by re-using parameters from a previous build on a non-dependent build configuration? Perhaps I can help you find an efficient solution.

0

Sure Parent is related to our code base, and most subprojects are stages, eg test and prod. But my is a specific project that works on multiple stages. The parameter I want is related to version/branch info. So Parent doesn't have enough info to set it.

I'm thinking one solution might be to have the build job grab the parameter from the api then use it to set the build number pattern.

0

You can absolutely use the API to grab version/branch information from a separate previous build. Any other parameters that were passed into the build would also be available in this way. 

0

Please sign in to leave a comment.