Launching a Sandbox from the Bamboo Plan

  • 19 April 2021
  • 0 replies

To verify that the Bamboo plugin was installed and configured correctly, launch a sandbox from your Bamboo plan. Note that this plugin only supports sandbox environments.

Use the available build steps to create a sandbox with necessary tasks from any blueprint, retrieve its details, start your tests and end the sandbox when it's no longer needed. For additional information, see the Bamboo plugin’s README.

Launching a Sandbox from your Plan

Open Bamboo and perform the following steps:

  1. From the top toolbar, click Projects.
  2. From the list, click the Project you want to work with.
  3. From the list, click the Plan you want to work with.
  4. From the Actions drop-down menu, select Configure plan.
  5. On the Stages tab, select the job to execute.
  6. Click Add task.
  7. The Task types menu displays. Search for Torque. Click the Start Torque Sandbox button and update the following parameters. When done, click Save.
    • Space Name: Enter the name of your Torque space.
    • Blueprint Name: Enter the name of the environment blueprint you would like to use for creating this sandbox.

      NOTE: To specify one of the Torque's sample blueprints, use a [Sample] prefix, i.e. [Sample]Java Spring Website AWS EU (Ireland) or [Sample]Java Spring Website Azure (West US).

    • Sandbox name: Enter a name for your sandbox.


      • Make sure this is descriptive so you will easily find the Sandbox in the future.
      • This task uses the ${bamboo.SANDBOX_ID} variable to return the identifier of sandbox.
    • Artifacts: If your blueprint requires artifacts, enter a comma separated list of artifacts in the following format: [artifact name]=[artifact location].
    • Inputs: If your blueprint requires inputs, enter a comma separated list of inputs in the following format: [input name]=[input value].
  8. Repeat step 7 for the Wait for Torque Sandbox and End Torque Sandbox tasks.
  9. From the Run drop-down menu, select Run plan.

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.

Example for retrieving the sandbox's details in JSON format

After launching the sandbox, the Wait for Torque Sandbox task will add the sandbox’s details to the environment variables with the name you provided. You can access the sandbox details from any of the other tasks using the following format: ${bamboo.Sandbox_Details}. Where “SANDBOX_DETAILS” is the variable name you defined in the Wait for Torque Sandbox task, as explained in the Bamboo plugin’s README.

The following is an example of how to get the sandbox’s details from a Python script (by accessing the Sandbox_Details environment variable): 

import json
import os

sandboxDetailsJsonStr = os.environ['bamboo_Sandbox_Details']
sandboxDetails = json.loads(sandboxDetailsJsonStr)

blueprintNameTag = next(tag for tag in sandboxDetails["tags"] if tag["name"] == "blueprint-name")
sandboxNameTag = next(tag for tag in sandboxDetails["tags"] if tag["name"] == "sandbox-name")

print(f'The blueprint "{blueprintNameTag["value"]}" has started as sandbox "{sandboxNameTag["value"]}".')
print(f'Current sandbox status: {sandboxDetails["sandbox_status"]}')

for app in sandboxDetails["applications"]:
for port in app["internal_ports"]:
print(f'The app {app["name"]} is listening internally at: {app["private_address"]}:{port}')

for port in app["external_ports"]:
print(f'The app {app["name"]} is listening externally at: {app["public_address"]}:{port}')

Note that the sandbox details variable is named bamboo_Sandbox_Details and not in Bamboo format - ${bamboo.Sandbox_Details}. This is because in this example, we accessed the environment variable from a script launched by the pipeline and therefore the format follows Bamboo conventions for external scripts.

0 replies

Be the first to reply!