Integrating with TeamCity
Anka Teamcity plugin provides a quick way to integrate Anka macOS Cloud with Teamcity CI for iOS/macOS CI workflows using your own private cloud. Anka VMs can be provisioned and allocated on-demand for execution of Teamcity initiated projects.
Preparing the VM Environment
Install Java 8 for Teamcity agent
First, prepare your macOS VMs that you will use as VM templates in Teamcity with Teamcity agent pre-requisites like Java8 and Teamcity user.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" brew update brew tap caskroom/versions brew cask install java8
User account configuration
Create a dedicated (Teamcity) user and enable remote login for this user in the VM template. Make sure to enable auto login for the administrative user of the VM as well.
Configure port forwarding
This step is needed to prepare the VM for ssh connection from Teamcity. Shut down the VM using
anka stop VMNAME. Enable port forwarding for this VM for ssh port 22 using the following command:
anka modify add port-forwarding [OPTIONS] RULE_NAME Options: --host-port INTEGER the port to listen on the host [required] --guest-port INTEGER the port to forward to on the vm [required] --protocol TEXT protocol to forward (tcp by default) [optional] --host-ip TEXT the forwarding server will listen to this ip address, defaults to 0.0.0.0 (all) [optional] --guest-ip TEXT specifies guest ip, in case the guest has multiple ips [optional] --card-index INTEGER specify the network cards index in case there is more than one [default: 0; optional] anka modify VMNAME add port-forwarding --host-port 0 --guest-port 22 --protocol tcp teamcityssh
RULENAME is a text name you can provide to this port forwarding rule. You can configure multiple port forwarding rules.
Pushing Teamcity agent executable to the VM Template
First, start the VM template with
anka start VMName.
Go to Agent push section in Teamcity interface. Select agent install.
Configure details for Teamcity to push the agent executable to the running VM template.
Host is the host IP of the machine where the VM Template is running.
SSH port is host forwarded port for the VM ssh port 22. Find this by running
anka show VMNAME on the VM Template. If there is only one port forwarding rule configured on the VM, then this will usually be 10000.
password are the Teamcity user you created in the previous step. Click on
Teamcity will now start installing agent executable in the VM Template.
After Teamcity agent installation is complete, ssh or
anka view to the running VM Template and go to
BuildAgent/conf/buildagent.properties file under Teamcity user. You will see serverurl pointing to your Teamcity server IP as
serverUrl=http://xx.xxx.xx.xxxserverUrl=http://xx.xxx.xx.xxx. Remove the extra
serverUrl=http://xx.xxx.xx.xxx string from this location. Save the file. Then, start the Teamcity agent service inside the VM with
sh BuildAgent/bin/mac.launchd.sh load.
Wait for few minutes for Teamcity to connect and authorize the VM agent instance. It will show up under the connected tab in Agents.
Now, suspend the Vm with
anka suspend VMName command. The VM Template is ready with all Teamcity executable dependencies.
Suspend and push this VM Template to anka registry.
Setup the Anka Teamcity Plugin
Install the Anka Plugin
Anka-Teamcity plugin is available for download in Teamcity Plugin repository - https://plugins.jetbrains.com/plugin/10733-anka-build-cloud.
administration section of your Teamcity and
Plugins List. Upload the previously downloaded
ankaCloud.zip file. This will install the plugin on your Teamcity server.
Configure the Anka Build Cloud details in the Teamcity Plugin
Go to your project settings and then,
Cloud Profiles. Click on
Create new profile and select
Anka Build Cloud from the drop-down.
Define Anka Build cloud profile for your project.
server url is the url for your Teamcity server.
Controller Host is the IP of your Anka Build Cloud controller module and
Controller port is the actual port. If you are using the default settings, then enter 8090.
image name drop-down, select the VM Template you pushed to the registry with Teamcity executable installed.
image tag, select the specific tag you provided to your VM Template or leave it to
Latest to pull the most recent one.
SSH User and
SSH Password is the Teamcity user credentials you created in the macOS VM Template.
Agent Path is the directory path where the Teamcity agent is installed on the VM Template.
Node Group Use the default setting for this, This is available for future feature release in the controller.
After you save the cloud profile, Teamcity automatically starts an agent on the cloud to test the setup. See the agent provisioned and connected in the Anka Build Controller portal view and also in the Teamcity Agents/Cloud tab.
You can stop this agent. The plugin setup is complete now.