How to pass a parameter to a trigger
Completed
I need to add a build(say build B) as a trigger within another build(say build A). Now build B should only be triggered from build A if the parameter 'isTriggerRequired' within build A is set as true. So please let me know how can I achieve this?
Also I am new in teamcity, so can you please explain the solution in some detail with example(s)
Please sign in to leave a comment.
Hello,
As of now it is not possible to trigger a build basing on some parameter out of the other build context. What you could do, though, is to start (or to not start) a build via custom command line script step which would call TeamCity REST API (https://www.jetbrains.com/help/teamcity/rest-api.html). For example, you could have a script which would invoke a below REST API call:
(where buildConfID is the ID of configuration you need to trigger). You may control whether the request is made or not within the script, or you can use conditional build steps feature (https://blog.jetbrains.com/teamcity/2020/07/new-in-2020-1-conditional-build-steps/).
I hope this helps.
Hi RG. If I understood your use case correctly, you need to run build A, and if if the parameter 'isTriggerRequired' is set to true, trigger build B from build A.
To do that:
1. Add a step to build A which runs a script that sending a POST request to
http://teamcity:8111/app/rest/buildQueue
to trigger a build via REST API based. Here's an example in PowerShell of such a script:2. In the build step settings add a condition: "isTriggerRequired equals true".
3. Replace the $buildConfigurationId, $branchName, $uri, and $token with the actual values.
Is that what you were looking for?
Hi Antoly
Yes this is exactly what I want. Thanks!!!