Configuring Jenkins Pipeline for iOS CI to run on Anka Build macOS cloud

In this blog, we will describe steps to run Jenkins iOS CI jobs defined as pipelines on macOS slave VMs running on Anka Build Anka Build macOS cloud. One of our previous blog titled “configuring Jenkins iOS CI macOS cloud” covered the basic steps to configure Jenkins-Anka Build plugin and steps to use it in Jenkins iOS CI jobs defined through web UI. Jenkins pipeline provides an extensible set of tools for modeling simple-to-complex delivery pipelines “as code” via the Pipeline Domain Specific Language (DSL) syntax. When using it in combination with Anka Build macOS cloud, the steps are relatively straightforward.

Step 1 – Install and setup Anka Build Jenkins plugin.

Step 2 – Set Anka Build macOS private cloud IP details in the plugin.

Step 3 – Create Anka macOS VM Slave templates to use for your iOS CI jobs. In this step, you will define a label for each of these slave templates.

ANka Build plugin Slave template

Step 4 – Define your Jenkins pipeline – https://github.com/asafg6/jenkins2-pipeline-example. This example is a simple pipeline definition which executes Build and Test scripts/actions. The pipeline launches Anka macOS VMs (Jenkins slaves) on-demand on Anka Build cloud as per the label definition.

Sample Jenkins Pipeline Job

Using Anka Build Slave template label in Pipeline definition

Step 5 – When this pipeline executes, it launches one or multiple macOS VMs on-demand for job execution. Every build and test job gets a sterilized, consistent environment.

Pipeline jobs executing on Anka Build macOS cloud

If you are using other declarative CI tools or platforms like Gitlab CI or Buildkite, you can use anka command line tool interface for easy integration with agents/runners. In such scenarios, the agent/runners running on macOS hosts will be able to launch on-demand Anka macOS VMs from templates (pulled from Anka Registry) , to fulfill job requests. We will be covering these scenarios in our upcoming blogs.

Running a macOS cloud on mac mini cluster for iOS CI

It’s been twelve years since the introduction of the first Mac mini. During these twelve years, there have been multiple updates and new models introduced with the last one in 2014. In 2011 the Mac Mini was updated with the power of i5 and i7 processors, and users started using it for the first time in a server capacity, namely as chat, web, mail servers. Then, 2012 Mac mini had exciting updates and demonstrated significant improvement in benchmarks from 2011. 2012 model is still very widely used since it was the last model with a quad-core processor.

When iOS development took off, Mac mini became the hardware of choice for app development because of it’s small form factor and the power it packs in this form. First, it was individuals developing iOS apps, then as the complexity of apps increased, the size of iOS development teams also increased. Teams started implementing DevOps and continuous integration and testing to keep up with the increased frequency of commits. Mac mini was again hardware choice for CI because teams could stack a bunch of these and get a build/test cluster going.

What’s happening now is that there is no end in sight for the richness of features you see in the mobile applications. “iOS First” philosophy still holds healthy for the majority of mobile application development. As a result, iOS development teams are finding themselves having to build more agile and flexible build and test infrastructure that can scale with the exponentially increasing number of UI regression tests, commit frequency, shorter update cycles and a gradually growing matrix of iOS device types.

In this blog, we will describe how you can configure your existing iOS build/test Mac mini hardware into a macOS cloud and operate CI in a docker like fashion.

  • Instant start (quick boot) multiple macOS VMs on-demand from a suspended state to run jobs in parallel.
  • Eliminate the complexity of SAN and other challenges associated with management of traditional virtualization platforms.
  • My example setup consists of 2 dual-core Mac minis(which are hosted in Macstadium). My CI system is Jenkins and I am using the Kickstarter open source iOS project to demonstrate build/test job example. If your CI tool is not Jenkins but some other on-prem tool like TeamCity or hosted tool like Buildkite or Gitlab, contact us to get more details on integration. We are working to release more pre-packaged integrations with other CI tools.

    Start by signing up for Anka Build 30 day trial software at www.veertu.com. You will receive an email with links to download the following Anka Build modules.

    Anka Build package – Mac application package which you will install on your Mac minis. Anka Build package is the virtualization hypervisor (lightweight 41MB package).

    Anka Controller – This is the Anka Build macOS cloud management module packaged as an ubuntu docker container.

    Anka Registry – This is similar to docker registry and is used to store and manage the macOS VMs and versions you build for your CI jobs.

    Anka Build Jenkins Plugin – This is the pre-built plugin available for download from Jenkins plugin center to easily integrate with Anka Build macOS cloud.

    Once you have installed all the above components, you should see the following:

    Anka Build macOS cloud configured in your Jenkins master instance

    Anka Build Jenkins Plugin



    Anka Build macOS cloud of 2 Mac minis(Data accessed through controller REST API)

    Anka Build Controller Node list



    Anka Build macOS cloud access to VM templates in Anka Registry

    Anka Build Controller Registry access REST API



    Anka Build Registry displaying versions of a VM template

    Anka Build Controller Registry VM Template Describe REST API



    Starting multiple iOS jobs to execute on the macOS CI cloud in Jenkins



    Three VMs are launched from VM template and instantly started on a cluster of 2 Mac mini nodes

    Quick boot/Instant Start for macOS VMs

    Anka Build Controller display VM list REST API output



    Displaying access through VNC to VMs launched on the Mac mini macOS cloud

    macOS VMs



    Highlights
  • Scale the macOS cloud by joining new Mac minis with Anka Build package installed to the Controller.
  • Use anka run to fully automate bootstrap/pre-configuration of build/test macOS VM templates. Check anka run documentation here.
  • Configure macOS cloud on on-premise or hosted Mac minis.
  • Launching build/test environment for iOS CI jobs at AWS instance launch speeds

    In this blog, we will describe how teams can configure a private (on-prem or hosted) cloud and instantaneously launch on-demand, isolated build/test instances to execute their iOS CI jobs, while still meeting the tough demands of the speed of overall execution of the CI jobs.

    It’s no secret that speed of CI job execution directly impacts developer productivity and you see developer productivity teams making this one of their top priorities. There are multiple variables that impact the speed of execution of the CI jobs – provisioning time for the environment, seeding the environment for the CI job (config mgmt etc), performance in the environment and getting build/test artifacts in and out of the environment.

    If you look outside of macOS dependent development, most of the CI process is happening either in private or public clouds. In these setups, (taking the example of AWS) launching an instance on-demand is super easy, completely extensible and fast. Just start one with an AMI and you have an isolated Linux instance available. Containers make it even easier and more replicable. However, the story is quite different for macOS dev environments for CI.

    Existing virtualization approach to creating a macOS dev cloud on Mac hardware is based on the same solution available to virtualize Linux and Windows. However, since this technology is not optimized for a macOS cloud use case, it suffers from challenges of scalability and manageability and only supports specific mac hardware.

    In the Anka Build solution, our goal was to make sure that these challenges are addressed and that it provides the same level of agility and scalability as one would get from using AWS. So, Anka Build packages a virtualization software that can run on any mac hardware, is built on top of macOS native Hypervisor Framework, exposes an extensible CLI.

    Let’s look at the method of provisioning or launching macOS VMs on-demand in Anka Build.

    Step 1 – Create your macOS Anka VM (this will be your template) and seed it with all your build/test dependencies using Anka CLI. This will ensure that no time is spent on preparing the dependencies in the environment for when a job runs.

    Step 2 – Put this Anka VM (template) in an ‘Instant Start’ State. It’s called `suspend` state in Anka CLI. This will ensure that when your iOS CI job requests an environment, the macOS Anka VM will be available instantly for execution, without any boot time issues. It will also ensure that you always get the same, consistent instance for repeated execution of the same job.

    Demo Video for Instant starting Anka macOS Vm from a suspended state.

    Step 3 – Push the suspended Anka VM to Anka registry.  If you need different flavors of build/test instances for different types of CI jobs, then, create and push different versions of same Anka VM template to the registry and use them by referring to a specific tag in your jobs. You can also create additional Anka VM templates(for when you need different macOS version) and push them to the registry and use them for your CI jobs.

    Step 4 – Install Anka Build mac application on all your build and test mac hardware and join them to Anka Build controller.

    Step 5 – Integrate your CI system to Anka Build controller through one of our existing plugins(Jenkins) or through REST APIs. Anka Build controller will now launch one or multiple macOS VMs on-demand across your build and test mac hardware, based on your CI job requests and your jobs will execute instantaneously.

    Step 6 – Trash the macOS Anka instances or keep them for troubleshooting. Get consistent, isolated instances for the next job execution.

    Step 1 and Step 2 address the tough demands of developer productivity teams to provide faster provisioning time of the macOS build/test instances in a macOS cloud for CI and enables them to keep build and test queue moving along with increased speed, efficiency, and determinism.