1. quali/cloudshell-colony@1.0.4

quali/cloudshell-colony@1.0.4

Sections
This orb integrates CloudShell Colony into your CI/CD pipeline. You can use the available build tasks to create a sandbox from any blueprint, start your tests and end the sandbox when finished. To use this orb you need to have an account in CloudShell Colony and API token The source code for this orb can be found here https://github.com/QualiNext/cloudshell-colony
Created: September 23, 2019Version Published: September 25, 2019Releases: 5
Org Usage:
< 25

Orb Quick Start Guide

Use CircleCI version 2.1 at the top of your .circleci/config.yml file.

1 version: 2.1

Add the orbs stanza below your version, invoking the orb:

1 2 orbs: cloudshell-colony: quali/cloudshell-colony@1.0.4

Use cloudshell-colony elements in your existing workflows and jobs.

Opt-in to use of uncertified orbs on your organization’s Security settings page.

Usage Examples

fetch-info

Start sandbox, echo its full description, stop sandbox

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 jobs: build: docker: - image: circleci/ruby:2.4.1 steps: - colony/start-sandbox: artifacts: '{''app-frontend'':''latest/my-app.latest.tar.gz''}' blueprint: my-application inputs: '{''AWS_INSTANCE_TYPE'': ''m5.large''}' sandbox-name: test-sandbox - run: command: echo "Sandbox ID is ${SANDBOX_ID}" name: Fetch Details - colony/end-sandbox: sandbox-id: SANDBOX_ID orbs: colony: quali/cloudshell-colony@1 version: 2.1 workflows: easy: jobs: - build

test-app

This example demonstrates how you can build and test your app using Colony Orb. First build app and publish it to s3 bucket. Than deploy CloudShell Colony Sandbox with your new application as an artifact parameter and do some testing against the endpoint of your deployed application.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 jobs: build-and-publish: docker: - image: circleci/ruby:2.4.1 steps: - checkout - run: command: | mkdir -p workspace tar -zcf my-webapp.latest.tar.gz -C my_app/ . name: Archive app - aws-s3/copy: from: my-webapp.latest.tar.gz to: s3://my-webapp-artifacts/latest/ orbs: aws-s3: circleci/aws-s3@1.0.11 colony: quali/cloudshell-colony@1.0 version: 2.1 workflows: leadeasy: jobs: - build-and-publish - colony/sandbox: artifacts: '{''webapp-frontend'':''latest/my-webapp.latest.tar.gz''}' blueprint: my-web-application inputs: '{''AWS_INSTANCE_TYPE'': ''m5.large''}' name: Test Application requires: - build-and-publish sandbox-name: test-sandbox steps: - run: echo "Do some testing here" - run: command: > echo "Getting application endpoint" SB_ENDPOINT="SB_${SANDBOX_ID}_SHORTCUT_1" echo "Checking ${!SB_ENDPOINT}" curl --write-out "%{http_code}\n" --silent --output /dev/null "${!SB_ENDPOINT}"

Jobs

sandbox

Run your build scenario once sandbox environment is ready.

Show job Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
artifacts
String with the list of artifacts. Json format {'key1': 'value1', ..., 'keyN': 'valueN'}
No
'{}'
string
blueprint
Name of the blueprint used for creating a Colony sandbox.
Yes
-
string
colony-token
Name of environment variable containing Colony API Token
No
CS_COLONY_TOKEN
env_var_name
colony-url
URL of Colony Server
No
CS_COLONY_SERVER
env_var_name
image
The name of image
No
circleci/python
string
inputs
String with the list of inputs. Json format {'key1': 'value1', ..., 'keyN': 'valueN'}
No
'{}'
string
sandbox-name
Name of sandbox.
No
circleci-orb-sandbox
string
space
Name of Colony space
No
CS_COLONY_SPACE
env_var_name
steps
Steps to execute once the Colony Sandbox is available
Yes
-
steps
tag
The image version tag
No
latest
string

Commands

end-sandbox

Stops CloudShell Colony sandbox environment

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
colony-token
Name of environment variable containing Colony API Token
No
CS_COLONY_TOKEN
env_var_name
colony-url
URL of Colony Server
No
CS_COLONY_SERVER
env_var_name
sandbox-id
Environment variable with the ID of the sandbox
No
SANDBOX_ID
env_var_name
space
Name of Colony space
No
CS_COLONY_SPACE
env_var_name

start-sandbox

Launches CloudShell Colony Sandbox from a blueprint

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
artifacts
String with the list of artifacts. Json format {'key1': 'value1', ..., 'keyN': 'valueN'}
No
'{}'
string
blueprint
Name of the blueprint used for creating a Colony sandbox.
No
''
string
colony-token
Name of environment variable containing Colony API Token
No
CS_COLONY_TOKEN
env_var_name
colony-url
URL of Colony Server
No
CS_COLONY_SERVER
env_var_name
duration
Duration (ISO 8601), after which CloudShell Colony will stop the deployment
No
PT2H
string
inputs
String with the list of inputs. Json format {'key1': 'value1', ..., 'keyN': 'valueN'}
No
'{}'
string
sandbox-details-variable
The name of environment variable which will be used to store full information about sandbox
No
SANDBOX_DETAILS
string
sandbox-id-variable
The name of environment variable which will be used to store sandbox id
No
SANDBOX_ID
string
sandbox-name
Name of sandbox.
No
circleci-orb-sandbox
string
space
Name of Colony space
No
CS_COLONY_SPACE
env_var_name
timeout
Timeout for this step in minutes. If the sandbox will not be ready when the timeout is reached, CloudShell Colony will abort the deployment
No
30
integer

Executors

default

The sample executor. Any executor with curl pre-installed can be used instead

Show executor Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
image
The name of image
No
circleci/python
string
tag
The image version tag
No
latest
string

Orb Source

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 # This code is licensed from CircleCI to the user under the MIT license. # See here for details: https://circleci.com/developer/orbs/licensing commands: end-sandbox: description: | Stops CloudShell Colony sandbox environment parameters: colony-token: default: CS_COLONY_TOKEN description: | Name of environment variable containing Colony API Token type: env_var_name colony-url: default: CS_COLONY_SERVER description: | URL of Colony Server type: env_var_name sandbox-id: default: SANDBOX_ID description: | Environment variable with the ID of the sandbox type: env_var_name space: default: CS_COLONY_SPACE description: | Name of Colony space type: env_var_name steps: - run: command: | curl --silent -X DELETE "$<<parameters.colony-url>>/api/spaces/$<<parameters.space>>/sandbox/$<<parameters.sandbox-id>>" \ -H "accept: text/plain" -H "Authorization: bearer $<<parameters.colony-token>>" || exit 1 name: End CloudShell Colony Sandbox start-sandbox: description: | Launches CloudShell Colony Sandbox from a blueprint parameters: artifacts: default: '{}' description: | String with the list of artifacts. Json format {'key1': 'value1', ..., 'keyN': 'valueN'} type: string blueprint: default: "" description: | Name of the blueprint used for creating a Colony sandbox. type: string colony-token: default: CS_COLONY_TOKEN description: | Name of environment variable containing Colony API Token type: env_var_name colony-url: default: CS_COLONY_SERVER description: | URL of Colony Server type: env_var_name duration: default: PT2H description: | Duration (ISO 8601), after which CloudShell Colony will stop the deployment type: string inputs: default: '{}' description: | String with the list of inputs. Json format {'key1': 'value1', ..., 'keyN': 'valueN'} type: string sandbox-details-variable: default: SANDBOX_DETAILS description: | The name of environment variable which will be used to store full information about sandbox type: string sandbox-id-variable: default: SANDBOX_ID description: | The name of environment variable which will be used to store sandbox id type: string sandbox-name: default: circleci-orb-sandbox description: | Name of sandbox. type: string space: default: CS_COLONY_SPACE description: | Name of Colony space type: env_var_name timeout: default: 30 description: | Timeout for this step in minutes. If the sandbox will not be ready when the timeout is reached, CloudShell Colony will abort the deployment type: integer steps: - run: command: | PAYLOAD=( "{ 'sandbox_name':'<<parameters.sandbox-name>>-${CIRCLE_BUILD_NUM}', 'blueprint_name':'<<parameters.blueprint>>', 'duration': '<<parameters.duration>>', 'inputs': <<parameters.inputs>>, 'artifacts': <<parameters.artifacts>>, 'automation': true }" ) echo $PAYLOAD sb=`curl --silent -X POST "$<<parameters.colony-url>>/api/spaces/$<<parameters.space>>/sandbox" \ -H "accept: text/plain" -H "Authorization: bearer $<<parameters.colony-token>>" \ -H "Content-Type: application/json" -d "$PAYLOAD"` || exit 1 sb=`echo $sb | sed 's/.*:"//' | sed 's/".*//'` echo "Sandbox with id $sb has been started" echo "export <<parameters.sandbox-id-variable>>=$sb" >> $BASH_ENV name: Deploy Colony Sandbox - run: command: | echo "Waiting for sandbox $<<parameters.sandbox-id-variable>>" timeout=`date --date="<<parameters.timeout>> minutes" +%s` status='' while [[ $(date +%s) -le $timeout && $status != "Active" ]]; do echo "****" sleep 25 details=`curl --silent \ -X GET "$<<parameters.colony-url>>/api/spaces/$<<parameters.space>>/sandbox/$<<parameters.sandbox-id-variable>>" \ -H "accept: text/plain" -H "Authorization: bearer $<<parameters.colony-token>>"` status=`echo $details | sed "s/.*\"sandbox_status\":\"//" | sed "s/\".*//"` echo "Status is $status" done if [[ $status != "Active" ]]; then echo "Timeout was reached or Sandbox is active with errors" exit 1 fi echo "export <<parameters.sandbox-details-variable>>=$details" >> $BASH_ENV var=1 for link in `echo $details | egrep -o '\["http?://[^ ]+*."\]' | sed 's/"//g' | tr -d '[],'` do echo "Writing quick link $link to environment variable SB_${<<parameters.sandbox-id-variable>>}_SHORTCUT_${var}" echo "export SB_${<<parameters.sandbox-id-variable>>}_SHORTCUT_${var}=$link" >> $BASH_ENV var=$((var+1)) done name: Wait For Sandbox description: | This orb integrates CloudShell Colony into your CI/CD pipeline. You can use the available build tasks to create a sandbox from any blueprint, start your tests and end the sandbox when finished. To use this orb you need to have an account in CloudShell Colony and API token The source code for this orb can be found here https://github.com/QualiNext/cloudshell-colony examples: fetch-info: description: | Start sandbox, echo its full description, stop sandbox usage: jobs: build: docker: - image: circleci/ruby:2.4.1 steps: - colony/start-sandbox: artifacts: '{''app-frontend'':''latest/my-app.latest.tar.gz''}' blueprint: my-application inputs: '{''AWS_INSTANCE_TYPE'': ''m5.large''}' sandbox-name: test-sandbox - run: command: echo "Sandbox ID is ${SANDBOX_ID}" name: Fetch Details - colony/end-sandbox: sandbox-id: SANDBOX_ID orbs: colony: quali/cloudshell-colony@1 version: 2.1 workflows: easy: jobs: - build test-app: description: | This example demonstrates how you can build and test your app using Colony Orb. First build app and publish it to s3 bucket. Than deploy CloudShell Colony Sandbox with your new application as an artifact parameter and do some testing against the endpoint of your deployed application. usage: jobs: build-and-publish: docker: - image: circleci/ruby:2.4.1 steps: - checkout - run: command: | mkdir -p workspace tar -zcf my-webapp.latest.tar.gz -C my_app/ . name: Archive app - aws-s3/copy: from: my-webapp.latest.tar.gz to: s3://my-webapp-artifacts/latest/ orbs: aws-s3: circleci/aws-s3@1.0.11 colony: quali/cloudshell-colony@1.0 version: 2.1 workflows: leadeasy: jobs: - build-and-publish - colony/sandbox: artifacts: '{''webapp-frontend'':''latest/my-webapp.latest.tar.gz''}' blueprint: my-web-application inputs: '{''AWS_INSTANCE_TYPE'': ''m5.large''}' name: Test Application requires: - build-and-publish sandbox-name: test-sandbox steps: - run: echo "Do some testing here" - run: command: "echo \"Getting application endpoint\"\nSB_ENDPOINT=\"SB_${SANDBOX_ID}_SHORTCUT_1\"\necho \"Checking ${!SB_ENDPOINT}\"\ncurl --write-out \"%{http_code}\\n\" --silent --output /dev/null \"${!SB_ENDPOINT}\" \n" executors: default: description: | The sample executor. Any executor with curl pre-installed can be used instead docker: - image: << parameters.image >>:<< parameters.tag >> parameters: image: default: circleci/python description: The name of image type: string tag: default: latest description: The image version tag type: string jobs: sandbox: description: | Run your build scenario once sandbox environment is ready. executor: image: <<parameters.image>> name: default tag: <<parameters.tag>> parameters: artifacts: default: '{}' description: | String with the list of artifacts. Json format {'key1': 'value1', ..., 'keyN': 'valueN'} type: string blueprint: description: | Name of the blueprint used for creating a Colony sandbox. type: string colony-token: default: CS_COLONY_TOKEN description: | Name of environment variable containing Colony API Token type: env_var_name colony-url: default: CS_COLONY_SERVER description: | URL of Colony Server type: env_var_name image: default: circleci/python description: The name of image type: string inputs: default: '{}' description: | String with the list of inputs. Json format {'key1': 'value1', ..., 'keyN': 'valueN'} type: string sandbox-name: default: circleci-orb-sandbox description: | Name of sandbox. type: string space: default: CS_COLONY_SPACE description: | Name of Colony space type: env_var_name steps: description: Steps to execute once the Colony Sandbox is available type: steps tag: default: latest description: The image version tag type: string steps: - checkout - start-sandbox: artifacts: <<parameters.artifacts>> blueprint: <<parameters.blueprint>> colony-token: <<parameters.colony-token>> colony-url: <<parameters.colony-url>> inputs: <<parameters.inputs>> sandbox-name: <<parameters.sandbox-name>> space: <<parameters.space>> - steps: <<parameters.steps>> - end-sandbox version: 2.1
Developer Updates
Get tips to optimize your builds
Or join our research panel and give feedback
By submitting this form, you are agreeing to ourTerms of UseandPrivacy Policy.