-
Notifications
You must be signed in to change notification settings - Fork 36
LocalTc
prayaas-a edited this page Jun 24, 2019
·
3 revisions
When your code is being executed as part of Team City build steps:
First, initialize a LocalTc object.
var localTc = new LocalTc();
Now, you can use various methods that are members of LocalTc to get or set Team City data.
-
Getting a pre-defined build parameter: You can access one of the predefined build parameters. For instance, let's access
teamcity.build.id
. In general, we do not consider prefixes to be part of the parameter name. Thus, you should pass "build.id" as the argument to GetBuildParameter(string parameterName).
var buildId = localTc.GetBuildParameter("build.id");
- Getting or setting a custom parameter: Custom build parameters must be set as a System Property. System properties will show up with a "system." prefix to their name. So, a custom defined parameter with the name "domain" shows up as "system.domain". Similar, to the example above, pass just "domain" as the argument. You can also set a value from code for non-readonly parameters:
localTc.SetBuildParameter("parameter.name", "value1");
- Setting build status: You can change build status from within your code.
localTc.ChangeBuildStatus(BuildStatus.Success);