Octopus.Script exported 2026-02-13 by wgunn-testery belongs to ‘Testery’ category.
Create an environment in your Testery account
Parameters
When steps based on the template are included in a project’s deployment process, the parameters below can be set.
Token
TesteryToken =
API token for your account. Found under Settings > Integrations
Name
TesteryName =
The display name for the environment
Key
TesteryKey =
The unique identifier for the environment
Maximum Parallel Test Run
TesteryMaximumParallelTestRuns = 0
The maximum number of test runs that can run in parallel on this environment. Default is 0 (no limit).
Pipeline Stage?
TesteryPipelineStage? =
The name of a pipeline stage to associate this environment to.
Variables?
TesteryVariables? =
Add variable to the environment. Specified as “KEY=VALUE”. To encrypt value, pass in “secure
Example:
FOO=BAR
secure:HELLO=WORLD
Fail if already exists?
TesteryExistsExitCode =
Mark if you want the step to fail if the environment already exists
Script body
Steps based on this template will execute the following Bash script.
set -e
TOKEN=$(get_octopusvariable "TesteryToken")
PIPELINE_STAGE=$(get_octopusvariable "TesteryPipelineStage?")
VARIABLES=$(get_octopusvariable "TesteryVariables?")
NAME=$(get_octopusvariable "TesteryName")
KEY=$(get_octopusvariable "TesteryKey")
MAX_PARALLEL=$(get_octopusvariable "TesteryMaximumParallelTestRuns")
FAIL_IF_EXIST=$(get_octopusvariable "TesteryExistsExitCode")
if [ "$FAIL_IF_EXIST" = "True" ] ; then
EXIST_EXIT=1
else
EXIST_EXIT=0
fi
VAR_ARGS=()
if [[ -n "$VARIABLES" ]]; then
mapfile -t VAR_LINES <<< "$VARIABLES"
for line in "${VAR_LINES[@]}"; do
[[ -z "$line" ]] && continue
VAR_ARGS+=("--variable" "$line")
done
fi
API_URL="https://api.testery.io/api/environments"
HTTP_RESPONSE=$(curl -s -w "\n%{http_code}" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
"$API_URL")
HTTP_BODY=$(echo "$HTTP_RESPONSE" | sed '$d')
HTTP_STATUS=$(echo "$HTTP_RESPONSE" | tail -n1)
# Check if the request was successful
if [ "$HTTP_STATUS" -ne 200 ]; then
echo "Error querying API:"
echo "Status Code: $HTTP_STATUS"
echo "Response: $HTTP_BODY"
exit 1
fi
export PATH="$HOME/.local/bin:$PATH"
# Check if an environment with the key exists using jq
ENVIRONMENT_EXISTS=$(echo "$HTTP_BODY" | jq -r --arg KEY "$KEY" '.[] | select(.key == $KEY) | .key')
if [ -n "$ENVIRONMENT_EXISTS" ]; then
echo "Environment with key already exists."
exit $EXIST_EXIT
else
pip install --user testery --upgrade
testery create-environment --token $TOKEN \
--name $NAME \
--key $KEY \
--maximum-parallel-test-runs $MAX_PARALLEL \
${PIPELINE_STAGE:+ --pipeline-stage "$PIPELINE_STAGE"} \
${VAR_ARGS:+ "${VAR_ARGS[@]}"}
fi
Provided under the Apache License version 2.0.
To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.
{
"Id": "b8e9e58d-f37f-48a5-a946-6da1a40742fa",
"Name": "Testery - Create Environment",
"Description": "Create an environment in your Testery account",
"Version": 1,
"ExportedAt": "2026-02-13T21:32:11.229Z",
"ActionType": "Octopus.Script",
"Author": "wgunn-testery",
"Packages": [],
"Parameters": [
{
"Id": "24613821-17c6-4648-b262-66d42c302e0f",
"Name": "TesteryToken",
"Label": "Token",
"HelpText": "API token for your account. Found under Settings > Integrations",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "Sensitive"
}
},
{
"Id": "54552cae-ed27-4b1a-a2df-85fd0a6b9018",
"Name": "TesteryName",
"Label": "Name",
"HelpText": "The display name for the environment",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Id": "1ba0af3c-9af0-46cd-896e-c42d0844fb25",
"Name": "TesteryKey",
"Label": "Key",
"HelpText": "The unique identifier for the environment",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Id": "051c9281-2cd6-404c-980d-05d1b608bbd2",
"Name": "TesteryMaximumParallelTestRuns",
"Label": "Maximum Parallel Test Run",
"HelpText": "The maximum number of test runs that can run in parallel on this environment.\nDefault is 0 (no limit).",
"DefaultValue": "0",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Id": "9cef03c4-ab66-498a-89f7-22552be12568",
"Name": "TesteryPipelineStage?",
"Label": "Pipeline Stage?",
"HelpText": "The name of a pipeline stage to associate this environment to.",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
}
},
{
"Id": "78d55e55-d4d8-432e-a4f1-09c7fbe62576",
"Name": "TesteryVariables?",
"Label": "Variables?",
"HelpText": "Add variable to the environment. Specified as \"KEY=VALUE\". To encrypt value, pass in \"secure:KEY=VALUE\", Multiple variables can be provided. Put each variable on a separate line.\n\nExample:\n```\nFOO=BAR\nsecure:HELLO=WORLD\n```",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "MultiLineText"
}
},
{
"Id": "a49dddf4-5af9-44ae-b682-9ab11e41d506",
"Name": "TesteryExistsExitCode",
"Label": "Fail if already exists?",
"HelpText": "Mark if you want the step to fail if the environment already exists",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "Checkbox"
}
}
],
"Properties": {
"Octopus.Action.Script.ScriptSource": "Inline",
"Octopus.Action.Script.Syntax": "Bash",
"Octopus.Action.Script.ScriptBody": "set -e\n\nTOKEN=$(get_octopusvariable \"TesteryToken\")\nPIPELINE_STAGE=$(get_octopusvariable \"TesteryPipelineStage?\")\nVARIABLES=$(get_octopusvariable \"TesteryVariables?\")\nNAME=$(get_octopusvariable \"TesteryName\")\nKEY=$(get_octopusvariable \"TesteryKey\")\nMAX_PARALLEL=$(get_octopusvariable \"TesteryMaximumParallelTestRuns\")\nFAIL_IF_EXIST=$(get_octopusvariable \"TesteryExistsExitCode\")\nif [ \"$FAIL_IF_EXIST\" = \"True\" ] ; then\n EXIST_EXIT=1\nelse\n EXIST_EXIT=0\nfi\nVAR_ARGS=()\nif [[ -n \"$VARIABLES\" ]]; then\n mapfile -t VAR_LINES <<< \"$VARIABLES\"\n for line in \"${VAR_LINES[@]}\"; do\n [[ -z \"$line\" ]] && continue\n VAR_ARGS+=(\"--variable\" \"$line\")\n done\nfi\n\nAPI_URL=\"https://api.testery.io/api/environments\"\nHTTP_RESPONSE=$(curl -s -w \"\\n%{http_code}\" \\\n -H \"Authorization: Bearer $TOKEN\" \\\n -H \"Content-Type: application/json\" \\\n \"$API_URL\")\n\nHTTP_BODY=$(echo \"$HTTP_RESPONSE\" | sed '$d')\nHTTP_STATUS=$(echo \"$HTTP_RESPONSE\" | tail -n1)\n\n# Check if the request was successful\nif [ \"$HTTP_STATUS\" -ne 200 ]; then\n echo \"Error querying API:\"\n echo \"Status Code: $HTTP_STATUS\"\n echo \"Response: $HTTP_BODY\"\n exit 1\nfi\n\nexport PATH=\"$HOME/.local/bin:$PATH\"\n\n# Check if an environment with the key exists using jq\nENVIRONMENT_EXISTS=$(echo \"$HTTP_BODY\" | jq -r --arg KEY \"$KEY\" '.[] | select(.key == $KEY) | .key')\n\nif [ -n \"$ENVIRONMENT_EXISTS\" ]; then\n echo \"Environment with key already exists.\"\n exit $EXIST_EXIT\nelse\n pip install --user testery --upgrade\n\n testery create-environment --token $TOKEN \\\n --name $NAME \\\n --key $KEY \\\n --maximum-parallel-test-runs $MAX_PARALLEL \\\n ${PIPELINE_STAGE:+ --pipeline-stage \"$PIPELINE_STAGE\"} \\\n ${VAR_ARGS:+ \"${VAR_ARGS[@]}\"}\nfi\n"
},
"Category": "Testery",
"HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/a381802920158308/step-templates/testery-create-environment.json",
"Website": "/step-templates/b8e9e58d-f37f-48a5-a946-6da1a40742fa",
"Logo": "iVBORw0KGgoAAAANSUhEUgAAALcAAACqCAYAAADvJt7aAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAbYSURBVHhe7Z3BkSNFEEV3sQATwAM8AM5c1gRM4MAdrpwAD8ADjtyAG0fwYPFgsQDqh6ZjZ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Jj45qgyt6SU61wS2tklNtcM8Ryak2hKJGcqoNIdmSnGpDeNYkp9qQhueSU21IiSSn2gAAAAAAAAAAAACvXv0P3aW8VNTlYhYAAAAASUVORK5CYII=",
"$Meta": {
"Type": "ActionTemplate"
}
}
Page updated on Friday, February 13, 2026