Create Turbo Containers Using Snapshots in CI

Snapshotting is a technique for creating images of virtual applications by detecting file system and registry modifications made during installation.

While many application can be installed directly into Turbo containers through a normal install process, some applications require the use of snapshots to create a working image.

This post explains how to create an automated pipeline for creating snapshot-based application images using Turbo Studio, Vagrant and Jenkins.

Vagrant was the subject of a recent Turbo Talk article. To learn more about Jenkins, an open source automation server, see their official website.

The Basics

Creating a virtual application image using snapshots is a multi-step process. It includes taking a snapshot of a clean operating system image before installing an application, performing the installation, and taking the second snapshot after the setup completes. Extra time is required for managing a virtual machine or downloading the application installer. Overall, building application images via snapshot manually is time consuming, so the process benefits dramatically from scaling via automation.

The TurboScript plugin for Jenkins provides a build step to automate creating snapshot-based application images. With a small amount of configuration Jenkins can perform all tasks necessary to create an application image via snapshot:

  • Boot a clean virtual machine,
  • Take a snapshot,
  • Install an application in a silent mode,
  • Take the second snapshot,
  • Build an application image,
  • Import an application image to the local repository on the host machine, and
  • Delete the virtual machine.

Features available off the shelf in Jenkins help to further customize the workflow by triggering a build by an external event, downloading an application installer or publishing an image to the Turbo.net Hub.

In this article, we will show how to create a Jenkins build project for FL Studio, a popular music production system.

Initial Setup

The configuration presented below was tested using Vagrant 1.7.4 and VirtualBox 4.3 installed on Windows 8.1 and Windows Server 2012 R2.

Before getting started, install Jenkins for Windows, available here.

Next, install Vagrant and VirtualBox. TurboScript plugin for Jenkins uses them internally to manage virtual machines.

Enable execution of PowerShell scripts on the Jenkins host machine. Run the command below in an elevated command prompt.
> powershell -Command Set-ExecutionPolicy RemoteSigned

The TurboScript plugin for Jenkins uses PowerShell to call external tools like Vagrant and Turbo Studio.

Last but not least, install Turbo Studio. An evaluation version of Turbo Studio can be downloaded here.

Configure Jenkins

Open the Jenkins Plugin Manager and install the latest version of TurboScript plugin.

SnapshotCi-InstallPlugin

Go to the Jenkins configuration page and scroll down to the Studio Snapshot section.

SnapshotCi-JenkinsGlobalConfiguration

Specify the file paths to XStudio.exe and a license file on Jenkins host machine.

If you installed Turbo Studio using default settings, XStudio.exe can be found in the C:\Program Files (x86)\Turbo.net\Turbo Studio 16 folder.

Optionally, you may want to change the default virtual machine used to take snapshots. Boxes are downloaded from Vagrant’s Atlas Service. The list of boxes is available here.

Create the Build Project

Go to the Jenkins dashboard and create a new Turbo Project. Name it FL Studio Snapshot and click OK.

SnapshotCi-CreateProject

Create a PowerShell script file which downloads the latest FL Studio installer. You can copy the code snippet below.

Optionally, the script may create an image.txt file in the current working directory. The file should contain the name of the output image. It is considered a best practice to include a product version. In the sample code below the product version is extracted from file attributes.

(New-Object System.Net.WebClient).DownloadFile(
    "http://support.image-line.com/redirect/FLStudio_Installer",
    "install.exe")
 $versionInfo = (Get-Item -Path "install.exe").VersionInfo
 $tag = ("{0}.{1}.{2}.{3}" -f $versionInfo.FileMajorPart,
     $versionInfo.FileMinorPart,
     $versionInfo.FileBuildPart,
     $versionInfo.FilePrivatePart)
 "flstudio:$tag" | Set-Content "image.txt"

Save the script file on the Jenkins host machine and execute it in a build step.

To add a build step, use the Execute Windows batch command option.

SnapshotCi-ExecuteBatchCommand

Specify the following command in the build step configuration.

powershell.exe -File "path_to_the_script"

Next, add a build step Take Studio snapshot and setup it in the following way.

SnapshotCi-TakeStudioSnapshot

Select the Generate using template option for installation script.

Specify /S to force a silent install.

Select the Ignore exit code checkbox.

Use a Fixed startup file set to @PROGRAMFILESX86@\Image-Line\FL Studio 12\FL.exe. For most applications, the default startup file selection made by Turbo Studio is sufficient.

Optionally, select the Overwrite checkbox if you want Jenkins to continue the build in case an image with the same version is already available in the Turbo.net Hub. Otherwise, the build will be aborted.

Save the build project and go back to the main Jenkins dashboard.

Trigger the Build

Open the context menu next to project name and click Build Now.

SnapshotCi-BuildNow

The build should finish in approximately half an hour. The FL Studio image will be saved in a local repository. If you want to publish it to the Turbo Hub, simply add the build steps Login to Turbo Hub and Push Turbo image.

Good Work!

Your snapshot build is now completely automated!

To create build projects for other applications, specify the appropriate set of silent install arguments and modify the PowerShell script to download the installer for that application.

Be sure to follow @turbohq for the latest tips and tricks or to ask any questions. If you need more help, email us at support@turbo.net.