Saturday, October 7, 2017

Deploy VSTS/TFS build agent with Xcode capability on a Mac

Make sure you have an updated version of Xcode.

Begin by opening a Terminal prompt and install the package manager Homebrew.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install OpenSSL.

brew update
brew install openssl
mkdir -p /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/

Install git.

brew install git

Restart Terminal and cd into the dir where you will create your agent dir.

Download https://github.com/Microsoft/vsts-agent/releases/download/v2.123.0/vsts-agent-osx.10.11-x64-2.123.0.tar.gz.
mkdir myagent && cd myagent
tar zxvf ~/Downloads/vsts-agent-osx.10.11-x64-2.123.0.tar.gz

Download the patched version of System.Net.Http from https://ci.dot.net/job/dotnet_corefx/job/release_1.1.0/job/osx_release/lastSuccessfulBuild/artifact/bin/build.tar.gz. Without this you won't be able to connect to VSTS/TFS.
tar -xzvf build.tar bin/Unix.AnyCPU.Release/System.Net.Http/System.Net.Http.dll

Make a backup of myagent/bin/System.Net.Http.dll before replacing it with the patched version.

Create a Personal Access Token by following https://docs.microsoft.com/sv-se/vsts/build-release/actions/agents/v2-osx#permissions.
Create a folder named LaunchAgents in /Users/[logged in user]/Library.

Configure the agent.

./config.sh

Accept terms: Y
Server URL: https://[your account].visualstudio.com
<enter> (PAT)
PAT: [your PAT]
<enter> (default agent pool)
pool name: []
<enter> (_work working folder)

Install and run the agent as a launchd service.

./svc.sh install

./svc.sh start

Source: https://docs.microsoft.com/sv-se/vsts/build-release/actions/agents/v2-osx#run-as-a-launchd-service.

No comments: