How to handle parallel installations of a tool on an agent?

I'm currently evaluating TeamCity, but found having some problems with the agent resource management via the 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.

Comment actions Permalink

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:

I created a feature request to better support multiple installations of Xcode on agents: Feel free to vote and leave comments.

As a workaround, you can use one of the following approaches:

  • Define agent parameters like xcode.13.2.1.path=<path> in, 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.
  • Another approach is to use the xcodes third-party tool. You can create build configuration parameters, say, xcode.path and xcode.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 the xcode.version parameter is defined. In this step, you can update the xcode.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 if xcode.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.

Comment actions Permalink

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 "" 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.

Comment actions Permalink
Happy to help, Robert!

Please sign in to leave a comment.