How to handle parallel installations of a tool on an agent? Follow
I'm currently evaluating TeamCity, but found having some problems with the agent resource management via the buildAgent.properties file.
I want to have multiple versions of Xcode installed on an agent and according to the specific version required by a build configuration set some environment variables like "XCODE_BIN" to the corresponding path. How would you implement this in TeamCity?
I tried some approaches to no avail but maybe with the wrong mindset, so I'm open to any suggestion.
Please sign in to leave a comment.
Hi Robert,
TeamCity agent can automatically detect only one active Xcode installation. To make an installation active, you should select it with the xcode-select tool as mentioned in this article: https://www.jetbrains.com/help/teamcity/xcode-project.html#Working+with+different+Xcode+setups.
I created a feature request to better support multiple installations of Xcode on agents: https://youtrack.jetbrains.com/issue/TW-79203/Detect-all-Xcode-installations-on-agent. Feel free to vote and leave comments.
As a workaround, you can use one of the following approaches:
xcode.13.2.1.path=<path>
in buildAgent.properties, and then use these parameters in the build runner settings in the 'Path to Xcode' field. This way, TC should automatically select an agent with the parameter defined, meaning agents without such parameters will be incompatible with the build configuration.xcode.path
andxcode.version
, and leave the default values empty. Then add a command-line build step before the Xcode build step. The command-line step should only be executed if thexcode.version
parameter is defined. In this step, you can update thexcode.path
value via service messages by running a simple shell command like one of the below (replace the specific version in grep with%xcode.version%
). With this approach, the Xcode build step should execute on the default Xcode ifxcode.version
is not defined at the start of the build. Otherwise, the build step should consider the path defined via the command-line build step.Hi Mikhail,
thanks a lot for your explanation and even taking the initiative to issue a feature request for that. For now I go with the first suggestion of your workarounds but adapted to our setup.
We have an overarching build step firing our pipeline of scripts with custom variables for the individual tasks. Therefor I need the variable XCODE_BIN set accordingly to be recognized by our Xcode compilation task. And I do so now by adding a TeamCity parameter with the name "env.XCODE_BIN" and value "%system.tools.xcode.12.4.bin%" for example. But the version number part there is in fact set dynamically when the build configuration is generated. And this we do with your Kotlin DSL.
So, with that whole mechanism in place we can now set the values of our variables to any tool and agent specifics and automatically get the right agent for the job because TeamCity recognizes it as an implicit requirement. With this I'm quite satisfied now and want to thank you again.