New

Launching a Sandbox from Jenkins Pipeline

  • 19 April 2021
  • 0 replies
  • 250 views

After installing and configuring the Jenkins plugin, you can start using the plugin to launch sandboxes from your Jenkins Pipeline. Note that this plugin only supports sandbox environments.

To use the plugin, you will need to instantiate a Blueprint object with using the torque global object. This object can then be used to start or end a Torque Sandbox. 
To view the built in documentation of the Jenkins Plugin, please follow these steps: 

Creating pipelines

  1. Create a new pipeline.
  2. Click Advanced Project Options and create a Pipeline script. Feel free to use our pipeline script examples for reference. Note that the Integration Tests section (shown in the above image) is the main section of the ‘start sandbox’ pipeline as it defines the details of the sandbox to be launched, and then the .startSandbox() line launches it, any deployment errors are caught using the catch(Exception e) element, and the finally part is triggered when the sandbox is active.
  3. Click Save.

Pipeline support (Workflow)

Blueprint:

  • Use torque.blueprint to define a Blueprint object that can then be used to perform operations on a blueprint.
    blueprint = torque.blueprint('blueprint_name', ['appname1': 'version', 'appname2': 'version'])
  • Use blueprint.startSandbox to starts a sandbox and returns a sandbox object which you could stop later.
    sandbox = blueprint.startSandbox()
  • Use blueprint.doInsideSandbox to starts a sandbox for the duration of the body.
    blueprint.doInsideSandbox{
    //code block
    }

Sandbox:

  • Use sandbox.end() to stop the sandbox.
    sandbox.end()

For reference, here's an example of a pipeline that starts a Torque sandbox:

def sandbox
 def artifacts = [:]
 def inputs = [Input1:"value1", input2:"value2"]
 
 sandbox = torque.blueprint("SpaceName", "BlueprintName", "SandboxName", "PT2H", artifacts, inputs, 15).startSandbox()

Where Input1 and Input2 are the input names of the blueprint, "PT2H” is the sandbox's scheduled uptime (2 hours, ISO 8601 format) and the timeout to create is 15 minutes

To learn more about creating a blueprint, see The Blueprint YAML File.

NOTE: In AWS environments, the applications may be inaccessible immediately after the environment becomes Active. This issue should resolve itself within a few moments when the AWS DNS propagation process completes.


0 replies

Be the first to reply!

Reply