How to get parent project name in properties?
Answered
I have a root project A that contains a subproject B. I know how to get the name of the current project, but how to get the name of the project A inside the parameters of the project B? I use Configuration Parameters.
Something like: %name_of_A%\% system.teamcity.projectName%
Please sign in to leave a comment.
Hello!
Unfortunately, as per my check we do not include parent project data into the build parameters. Could you please describe the use case where you would need this data in the build context dynamically?
You may access this property via REST API, though. during the build; the below endpoint could be accessed from a custom script (for instance, curl invoke) with buildID (which is available in the predefined parameters as teamcity.build.id):
/app/rest/projects/build:<buildID>/parentProjectName
This will return the parent project name if applicable (for projects with no custom parent it will return <Root project> instead). You may find more details on REST API usage at https://www.jetbrains.com/help/teamcity/rest-api.html
Hope this will prove helpful; please let me know in case of any questions!