How to pull code from different branches at runtime and pass parameter to NUnit.xml file?

Hi Team,

We recently moved Java(TestNG) to C#.Net (NUnit).  Sametime migrated to Jenkins to Team-city. Currently we are facing some challenges while we configuring the new build pipeline in Team-City.

Scenario 1:   Our project has multiple branches, we generally pull code from different Git-branches then trigger the automation.

In Jenkins we used to create build-parameter(list), when user try to execute the Job, he/she select the branch-name from the list (build-parameters), then git will pull code user selected branch then trigger execution.

  1. Can you please help how to implement a similar process in Team-City?
  2. How to configure the default value in the list parameter?

Scenario 2:  In Jenkins build-parameter use used to pass to (TestNG.xml). eg: browser, environment. When the user select browser and environment from build parameters, when execution trigger TestNG pull those values and initiate the regression.

  1. How should create build parameters (browser, envi.) and pass those values to NUnit/ config file?



1 comment
Comment actions Permalink
Hi! I am not sure I understand precisely how you want TeamCity to be configured. Here is what I have got from your description and what I suggest to do. Please check and let me know if this is what you are looking for.

As I understand, for Scenario 1, you need to be able to select which branch of the Git repo the build (Job) will checkout. You also want it to check out a certain branch by default if you don't specify any. To achieve that, do the following:

1. Go to your project settings > Version Control Settings > create or edit a VCS root pointing to your repo. (online help:
2. In the VCS root settings, specify the "Default branch" ref, e.g. refs/heads/master. That would be your default value in the list parameter in the branch selector ("default value in the list parameter"). (online help:
3. In the VCS root settings, specify the "Branch specification", e.g. +:refs/heads/*. That would define the other items in the branch selector ("build-parameter(list)"). (online help:
4. Make sure you create a build configuration (a.k.a. "Job" in Jenkins terminology) and attached the VCS root to the build configuration. (online help:
5. Go to build configuration overview page and select the required branch in the branch dropdown. You can find the dropdown list in the top left area of the build configuration overview page (under the build configuration name). Branches are populated once the VCS root has polled the repo for changes (either automatically or after you clicked Actions > Check for pending changes on the build configuration overview page).

For Scenario 2, I think you are looking for "Build Parameters" (online help: You can set those either in the Project settings or Build Configuration settings. The parameters can be either of the following:

* configuration parameters, whose values you can refer to in TeamCity configuration by specifying `%myParameterName%`. In the build runtime, it will be replaced by the parameter value.
* environment variables (parameters names prefixed with "env."), whose values you can refer to in your build scripts and in the code as you would refer to any other environment variable.
* system properties (parameters names prefixed with "system."), which are automatically passed into the build scripts of certain runners as variables specific to a build tool (more info:

Please sign in to leave a comment.