Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose TeamCity build properties dictionary via TeamCityBuildInfo #2967

Closed
augustoproiete opened this issue Dec 4, 2020 · 2 comments · Fixed by #3113 or #3145
Closed

Expose TeamCity build properties dictionary via TeamCityBuildInfo #2967

augustoproiete opened this issue Dec 4, 2020 · 2 comments · Fixed by #3113 or #3145
Milestone

Comments

@augustoproiete
Copy link
Member

augustoproiete commented Dec 4, 2020

Edit: Instead of parsing the .properties file, we'll parse the .properties.xml file instead implemented by @BlythMeister in #3113


TeamCity provides additional information about the build and the build agent through a text file that is written during the build.

This file contains a number of properties about the build that are not available via environment variables such as configuration parameters.

The location of the file is available during the build in the environment variable TEAMCITY_BUILD_PROPERTIES_FILE and looks something like C:\agentName\t\buildTmp\teamcity.build1035226021699882408.properties.

The file uses the java.util.Properties format (a.k.a. "Property Resource Bundles") and looks like this:

#TeamCity build properties without 'system.' prefix
#Fri Dec 03 19:52:06 AST 2020
agent.home.dir=C\:\\TeamCity\\buildAgent02
agent.name=DEV-TC-42
agent.ownPort=8082
agent.work.dir=C\:\\agent42\\w
build.number=v5.2.4-dev
java.io.tmpdir=C\:\\agent42\\t\\buildTmp
teamcity.agent.cpuBenchmark=489
teamcity.agent.dotnet.agent_url=http\://localhost\:8082/RPC2
teamcity.agent.dotnet.build_id=186380
teamcity.auth.password=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
teamcity.auth.userId=TeamCityBuildId\=186380
teamcity.build.changedFiles.file=C\:\\agent42\\t\\buildTmp\\changedFiles7806694707471261708.txt
teamcity.build.checkoutDir=C\:\\agent42\\w\\fd0d02f87a570f9d
teamcity.build.id=186380

I suggest exposing these properties via a name/value collection that returns the value of a property by its name (or null if name does not exist).

e.g.

var buildId = TeamCity.Build.Properties["teamcity.build.id"]; // 186380
var configSetting = TeamCity.Build.Properties["configSetting"]; // null

The workaround today is to read the TEAMCITY_BUILD_PROPERTIES_FILE environment variable from the Cake script and parse the file yourself, thus exposing these properties via TeamCityBuildInfo is for convenience.

@augustoproiete
Copy link
Member Author

Instead of parsing the .properties file, we'll parse the .properties.xml file instead implemented by @BlythMeister in #3113

@cake-build-bot
Copy link

🎉 This issue has been resolved in version v1.1.0 🎉

The release is available on:

Your GitReleaseManager bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants