Integrating with Jenkins

The Anka Jenkins plugin provides a quick way integrate Anka with Jenkins for iOS/macOS CI workflows using your own private cloud. Anka VMs can be allocated on-demand for execution of Jenkins build plans.

Preparing the VM Environment

Install Java for Jenkins

First, prepare your macOS VMs that you will use as VM templates in Jenkins with all necessary Jenkins JAR and Jenkins user access. This might include a dedicated Jenkins user within your VM template. One way to set up java dependencies for working with Jenkins is to execute the following commands in your VM template:

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

# Update Homebrew
brew update

# Add the caskroom tap
brew tap Caskroom/cask

# Install Java from the tap
brew install Caskroom/cask/java

User account configuration

Create a dedicated (Jenkins) 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

To prepare the VM for connections, shut down the VM using anka stop VMNAME. Enable port forwarding for this VM using the following command:

anka modify VMNAME add port-forwarding --host-port 0 --guest-port 22 --protocol tcp RULENAME

Additional VM Template Setup

First, make sure to install any other build and test dependencies used for your Jenkins workflows in your VM template. Then, push this VM to the Anka registry (which is connected to your Anka Controller) using the anka registry push command.

Configure the Anka Plugin

Install the Anka Plugin

Browse to Manage Jenkins > Manage Plugins and click on the Advanced tab. Use the instructions under the Upload Plugin section to upload the anka-ci.hpi plugin file to your Jenkins master server.

Then, go to Manage Jenkins > Configure System and find the section called Cloud. Enter a name for your Anka Cloud, as well as an IP address and port number for the controller.

image1

Next, click Show Templates and start configuring Jenkins slave templates for your jobs. Add multiple slave templates for different build and test job types as needed. While configuring the slave template, select your preconfigured VM template from Template drop down. Additionally select the version of the VM from the Template Version Tag dropdown.

image2

You can save multiple slave VM template profiles based on your needs. Then, associate your Jenkins job with a specific label and run your jobs on these dynamically provisioned and isolated VMs. Your VM template should provision itself and become available when the job is executed.