Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a build step conditionally in TeamCity

Tags:

This is a more generic version of this question: How to run a build step on a specific branch only?

For example, I can use a PowerShell script to run MSBuild if '%teamcity.build.branch.is_default%' -eq 'true' or if '%teamcity.build.branch%' -eq 'master' but then I will miss the collapsible log that comes with the TeamCity MSBuild build runner. Isn't there any easier way to conditionally run a build step?

like image 851
orad Avatar asked Oct 15 '15 21:10

orad


People also ask

How do you trigger a build in TeamCity?

To run a custom build with specific changes, open the build results page, go to the Changes tab, expand the required change, click the Run build with this change, and proceed with the options in the Run Custom Build dialog. Use HTTP request or REST API request to TeamCity to trigger a build.

How do you run a command in TeamCity?

General SettingsThe option is available if "Executable with parameters" is selected in the Run drop-down menu. Specify the path to an executable to be started. The option is available if "Executable with parameters" is selected in the Run drop-down menu. Specify space-separated parameters to pass to the executable.

What is meta runner in TeamCity?

A meta-runner allows you to extract build steps, requirements, and parameters from a build configuration and create a build runner out of them. This build runner can then be used as any other build runner in a build step of any other build configuration or template. With meta-runners, you can: Reuse existing runners.


1 Answers

It is not possible to execute build step based on condition. Vote for the related request: https://youtrack.jetbrains.com/issue/TW-17939.
The recommended approach is to create separate build configuration for each branch. You can use templates to simplify the setup. In this case it will be easier to interpret the results and the statistics of the builds will be informative.
Also see the related answer (hack is suggested).

like image 185
Alina Mishina Avatar answered Sep 19 '22 16:09

Alina Mishina