Unable to render embedded object: File (TeamCity48.png) not found.

TeamCity 2018.x Documentation

Documentation for Previous Versions

Icon

You are viewing the documentation of TeamCity 2018.x, which is not the most recently released version of TeamCity.
View this page in the latest documentation or refer to the listing to choose the documentation corresponding to your TeamCity version.

 

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Describe another way to start build agent on MacOS.

...

For macOS/Mac OS X, TeamCity provides the ability to load a build agent automatically when a build user logs in. For that, TeamCity uses standard macOS way to start daemon processes - LaunchDaemon plist files.To

Login Item approach (recommended)

The recommended way to do it is as follows:

  • Install a build agent on a Mac via buildAgent.zip
  • Prepare the conf/buildAgent.properties file (set agent name there, at least)
  • Make sure that all files under the buildAgent directory are owned by your_build_user to ensure a proper agent upgrade process.

  • Start the build agent via bin/agent.sh start command and make sure it upgrades successfully on the first start
  • Create a command file $HOME/start_build_agent.command which contains one line: 

    Code Block
    languagebash
    /path/to/buildAgent/bin/agent.sh start
  • Add this command file into Login Items via UI or use the following command from the Terminal app:

    Code Block
    languagebash
    osascript -e 'tell application "System Events" to make login item at end with properties {path:"/Users/your_build_user/start_teamcity_agent.command", hidden:false}'
  • Configure your Mac system to automatically login as a build user, as described here
  • Reboot

  • On the system startup, the build user should automatically log in, and the build agent should start from the Terminal app (you can close it after that).

To stop build agent, use the usual /path/to/buildAgent/bin/agent.sh stop command

 

LaunchAgent approach

To configure an automatic build agent startup via LaunchAgent, follow these steps:

  • Install

...

  • Install a build agent on a Mac via buildAgent.zip
  • Prepare the conf/buildAgent.properties file (set agent name there, at least)
  • Make sure that all files under the buildAgent directory are owned by your_build_user to ensure a proper agent upgrade process.

  • Load the build agent via command:

    Code Block
    titleRun these commands under your_build_user account
    languagebash
    mkdir buildAgent/logs  # Directory should be created under your_build_user user 
    sh buildAgent/bin/mac.launchd.sh load
    

    You have to wait several minutes for the build agent to auto-upgrade from the TeamCity server. You can watch the process in the logs:

    Code Block
    languagebash
    tail -f buildAgent/logs/teamcity-agent.log
  • When the build agent is upgraded and successfully connects to TeamCity server, stop it:

    Code Block
    languagebash
    sh buildAgent/bin/mac.launchd.sh unload
    
Configure automatic build agent start
  • After buildAgent upgrade from the TeamCity server, copy the buildAgent/bin/jetbrains.teamcity.BuildAgent.plist file to $HOME/Library/LaunchAgents/ directory.

Note

You can configure to start build agent on system boot, and place plist file to /Library/LaunchDaemons directory. But in this case there could be some troubles with running GUI tests, and with build agent auto-upgrade. So we do not recommend this approach.

See this external posting for some more details on LaunchDaemons.

Info

The old jetbrains.teamcity.BuildAgent.plist files bundled with TeamCity before 9.0.4 had a bug which prevent iOS simulator from starting on OS X Yosemite (TW-38954). The fix is to remove SessionCreate property from this file.

  • Configure your Mac system to automatically login as a build user, as described here
  • Reboot

...

    • Install the second build agent in a different directory

    • In conf/buildAgent.properties, you should specify an unique name for the build agent

    • Start and upgrade second agent via bin/agent.sh script
    • In bin/jetbrains.teamcity.BuildAgent.plist file, you should specify unique "Label" parameter (which is jetbrains.teamcity.BuildAgent by default)
    • When copying jetbrains.teamcity.BuildAgent.plist file to LaunchAgents, you should give it a different name
       
    • In the $HOME/start_build_agent.command, add a line to start the second build agent 

Stopping the Build Agent

To stop the agent manually, run the <Agent home>\agent script with a stop parameter.

...