diff --git a/src/commands/end-sandbox.yml b/src/commands/end-sandbox.yml index 4cbb8a9..c6994b2 100644 --- a/src/commands/end-sandbox.yml +++ b/src/commands/end-sandbox.yml @@ -26,6 +26,6 @@ steps: name: End Torque Sandbox command: | curl --silent -X DELETE "$<>/api/spaces/$<>/sandbox/$<>" \ - --header "User-Agent: Torque-Plugin-CirceCI/1.0.X" \ + --header "User-Agent: Torque-Plugin-CirceCI/1.1.X" \ --header "accept: text/plain" \ --header "Authorization: bearer $<>" || exit 1 diff --git a/src/commands/start-sandbox.yml b/src/commands/start-sandbox.yml index 1537f83..be465b6 100644 --- a/src/commands/start-sandbox.yml +++ b/src/commands/start-sandbox.yml @@ -42,12 +42,6 @@ parameters: Json format {'key1': 'value1', ..., 'keyN': 'valueN'} type: string default: "{}" - artifacts: - description: | - String with the list of artifacts. - Json format {'key1': 'value1', ..., 'keyN': 'valueN'} - type: string - default: "{}" timeout: description: > Timeout for this step in minutes. If the sandbox will not be ready when the timeout is reached, @@ -69,15 +63,14 @@ steps: 'blueprint_name':'<>', 'duration': '<>', 'inputs': <>, - 'artifacts': <>, 'automation': true }" ) echo $PAYLOAD status_code=`curl --write-out "%{http_code}\n" --output result.txt \ - --silent -X POST "$<>/api/spaces/$<>/sandbox" \ - --header "User-Agent: Torque-Plugin-CirceCI/1.0.X" \ + --silent -X POST "$<>/api/spaces/$<>/environments" \ + --header "User-Agent: Torque-Plugin-CirceCI/1.1.X" \ --header "accept: text/plain" \ --header "Authorization: bearer $<>" \ --header "Content-Type: application/json" -d "$PAYLOAD"` || exit 1 @@ -96,26 +89,36 @@ steps: echo "Waiting for sandbox $<>" timeout=`date --date="<> minutes" +%s` status='' - while [[ $(date +%s) -le $timeout && $status != "Active" ]]; do + prev_status='' + while [[ $(date +%s) -le $timeout ]]; do + url="$<>/api/spaces/$<>/environments/$<>" echo "****" - sleep 25 details=`curl --silent \ - -X GET "$<>/api/spaces/$<>/sandbox/$<>" \ - --header "User-Agent: Torque-Plugin-CirceCI/1.0.X" \ \ + -X GET "${url}" \ + --header "User-Agent: Torque-Plugin-CirceCI/1.1.X" \ --header "accept: text/plain" \ --header "Authorization: bearer $<>"` - status=`echo $details | sed "s/.*\"sandbox_status\":\"//" | sed "s/\".*//"` - echo "Status is $status" + status=`echo $details | sed "s/.*\"computed_status\":\"//" | sed "s/\".*//"` + if [[ $status != $prev_status ]]; then + echo "Status is $status" + prev_status=$status + fi + if [[ $status == "Active" ]]; then + break + fi + if [[ $status == "Ended" ]]; then + echo "Error: sandbox is ended" + exit 1 + fi + if [[ $status == "Active With Error" ]]; then + echo "Error: sandbox is active with error!" + exit 1 + fi + sleep 20 done if [[ $status != "Active" ]]; then echo "Timeout was reached or Sandbox is active with errors" exit 1 fi + echo "export <>=$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_${<>}_SHORTCUT_${var}" - echo "export SB_${<>}_SHORTCUT_${var}=$link" >> $BASH_ENV - var=$((var+1)) - done diff --git a/src/examples/fetch-info.yml b/src/examples/fetch-info.yml index cda0a01..2af6e69 100644 --- a/src/examples/fetch-info.yml +++ b/src/examples/fetch-info.yml @@ -3,7 +3,7 @@ description: | usage: version: 2.1 orbs: - torque: quali/torque@1 + torque: quali/torque@1.1 jobs: build: docker: @@ -13,7 +13,6 @@ usage: sandbox-name: "test-sandbox" blueprint: "my-application" inputs: "{'AWS_INSTANCE_TYPE': 'm5.large'}" - artifacts: "{'app-frontend':'latest/my-app.latest.tar.gz'}" - run: name: Fetch Details command: echo "Sandbox ID is ${SANDBOX_ID}" diff --git a/src/examples/test-app.yml b/src/examples/test-app.yml index 7076b59..07df5f8 100644 --- a/src/examples/test-app.yml +++ b/src/examples/test-app.yml @@ -7,7 +7,7 @@ usage: version: 2.1 orbs: - torque: quali/torque@1.0 + torque: quali/torque@1.1 aws-s3: circleci/aws-s3@1.0.11 jobs: build-and-publish: @@ -32,14 +32,12 @@ usage: sandbox-name: "test-sandbox" blueprint: "my-web-application" inputs: "{'AWS_INSTANCE_TYPE': 'm5.large'}" - artifacts: "{'webapp-frontend':'latest/my-webapp.latest.tar.gz'}" 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}" + echo "Getting sandbox details" + echo "You can process the json with jq and perform some tests" + echo "${SANDBOX_DETAILS}" requires: - build-and-publish diff --git a/src/jobs/sandbox.yml b/src/jobs/sandbox.yml index debe030..47052b4 100644 --- a/src/jobs/sandbox.yml +++ b/src/jobs/sandbox.yml @@ -31,12 +31,6 @@ parameters: Json format {'key1': 'value1', ..., 'keyN': 'valueN'} type: string default: "{}" - artifacts: - description: | - String with the list of artifacts. - Json format {'key1': 'value1', ..., 'keyN': 'valueN'} - type: string - default: "{}" steps: type: steps description: Steps to execute once the Torque Sandbox is available @@ -58,7 +52,6 @@ steps: sandbox-name: <> blueprint: <> inputs: <> - artifacts: <> torque-token: <> torque-url: <> space: <>