Cake: Enhance TeamCity provider

Created on 21 Dec 2016  路  9Comments  路  Source: cake-build/cake

This is for tracking enhancements to TeamCity provider so that it is similar to AppVeyor so you can do IsPullRequest etc in cake scripts

Feature

Most helpful comment

Environment variables are set on process level so it should not be a problem.

All 9 comments

@aateeque before doing too much work on this, might be worth adding some notes here about your direction, and how you are going to go about things, so that we can limit the amount of re-work that might be required.

So my first attempt is to get data from process env vars. To begin with, I naively assume that you will be using GitVersion which wants you to setup env.Git_Branch to correctly pickup pull-requests because TeamCity does not store git branch name in any vars. Following on from this assumption I just parse the name to see if it contains pull-requests to enable property IsPullRequest in a TeamCityPullRequestInfo object.
In terms of laying this out in code, I am following what we have in AppVeyor; so thinking of adding TeamCityBuildInfo, TeamCityEnvironmentInfo, etc.

Another approach discussed in #884 is to parse the .properties file. But so far I've only found the branch info to be missing in env vars (I am using ICakeEnvironment.GetEnvironmentVariable(string) to extract TeamCity parameters).

Thoughts on the assumption?

The useful env vars I have found on my agent are:

c# BUILD_NUMBER //build counter BUILD_VCS_NUMBER //git commit hash BUILD_VCS_NUMBER_{RootProjectId}_%TEAMCITY_PROJECT_NAME%_{VCS root ID} //git commit hash Git_Branch //%teamcity.build.vcs.branch.{VCS root ID}% TEAMCITY_BUILD_PROPERTIES_FILE //path to .properties file TEAMCITY_BUILDCONF_NAME //build config name TEAMCITY_CAPTURE_ENV //env-fetcher.jar cmd TEAMCITY_GIT_PATH //path to git.exe on agent TEAMCITY_JRE //path to TC JRE on agent TEAMCITY_PROCESS_FLOW_ID //process flow id for tracking TEAMCITY_PROCESS_PARENT_FLOW_ID //parent process flow id in the case of parallel processes TEAMCITY_PROJECT_NAME //build config project name TEAMCITY_VERSION //TC version string TEMP //path to agent temp dir

You likely already are using it @aateeque, but https://confluence.jetbrains.com/display/TCD10/Predefined+Build+Parameters is a terrific reference. I've used it extensively in the past when writing build scripts and when I did the first iteration of the TC provider.

fixed by #1433

Hi,

Can someone explain what will happen if you have several Team City agents running on the same machine and all of them starting to build different branches at the same time? Will be there a race condition for env.Git_Branch or not?

@aateeque , @devlead Guys, can you please clarify question above for me? Thanks

Environment variables are set on process level so it should not be a problem.

@patriksvensson , thanks!

Was this page helpful?
0 / 5 - 0 ratings