@@ -42,12 +42,6 @@ parameters:
4242 Json format {'key1': 'value1', ..., 'keyN': 'valueN'}
4343 type : string
4444 default : " {}"
45- artifacts :
46- description : |
47- String with the list of artifacts.
48- Json format {'key1': 'value1', ..., 'keyN': 'valueN'}
49- type : string
50- default : " {}"
5145 timeout :
5246 description : >
5347 Timeout for this step in minutes. If the sandbox will not be ready when the timeout is reached,
@@ -69,15 +63,14 @@ steps:
6963 'blueprint_name':'<<parameters.blueprint>>',
7064 'duration': '<<parameters.duration>>',
7165 'inputs': <<parameters.inputs>>,
72- 'artifacts': <<parameters.artifacts>>,
7366 'automation': true
7467 }"
7568 )
7669 echo $PAYLOAD
7770
7871 status_code=`curl --write-out "%{http_code}\n" --output result.txt \
79- --silent -X POST "$<<parameters.torque-url>>/api/spaces/$<<parameters.space>>/sandbox " \
80- --header "User-Agent: Torque-Plugin-CirceCI/1.0 .X" \
72+ --silent -X POST "$<<parameters.torque-url>>/api/spaces/$<<parameters.space>>/environments " \
73+ --header "User-Agent: Torque-Plugin-CirceCI/1.1 .X" \
8174 --header "accept: text/plain" \
8275 --header "Authorization: bearer $<<parameters.torque-token>>" \
8376 --header "Content-Type: application/json" -d "$PAYLOAD"` || exit 1
@@ -96,26 +89,36 @@ steps:
9689 echo "Waiting for sandbox $<<parameters.sandbox-id-variable>>"
9790 timeout=`date --date="<<parameters.timeout>> minutes" +%s`
9891 status=''
99- while [[ $(date +%s) -le $timeout && $status != "Active" ]]; do
92+ prev_status=''
93+ while [[ $(date +%s) -le $timeout ]]; do
94+ url="$<<parameters.torque-url>>/api/spaces/$<<parameters.space>>/environments/$<<parameters.sandbox-id-variable>>"
10095 echo "****"
101- sleep 25
10296 details=`curl --silent \
103- -X GET "$<<parameters.torque- url>>/api/spaces/$<<parameters.space>>/sandbox/$<<parameters.sandbox-id-variable>> " \
104- --header "User-Agent: Torque-Plugin-CirceCI/1.0 .X" \ \
97+ -X GET "${ url} " \
98+ --header "User-Agent: Torque-Plugin-CirceCI/1.1 .X" \
10599 --header "accept: text/plain" \
106100 --header "Authorization: bearer $<<parameters.torque-token>>"`
107- status=`echo $details | sed "s/.*\"sandbox_status\":\"//" | sed "s/\".*//"`
108- echo "Status is $status"
101+ status=`echo $details | sed "s/.*\"computed_status\":\"//" | sed "s/\".*//"`
102+ if [[ $status != $prev_status ]]; then
103+ echo "Status is $status"
104+ prev_status=$status
105+ fi
106+ if [[ $status == "Active" ]]; then
107+ break
108+ fi
109+ if [[ $status == "Ended" ]]; then
110+ echo "Error: sandbox is ended"
111+ exit 1
112+ fi
113+ if [[ $status == "Active With Error" ]]; then
114+ echo "Error: sandbox is active with error!"
115+ exit 1
116+ fi
117+ sleep 20
109118 done
110119 if [[ $status != "Active" ]]; then
111120 echo "Timeout was reached or Sandbox is active with errors"
112121 exit 1
113122 fi
123+
114124 echo "export <<parameters.sandbox-details-variable>>=$details" >> $BASH_ENV
115- var=1
116- for link in `echo $details | egrep -o '\["http?://[^ ]+*."\]' | sed 's/"//g' | tr -d '[],'`
117- do
118- echo "Writing quick link $link to environment variable SB_${<<parameters.sandbox-id-variable>>}_SHORTCUT_${var}"
119- echo "export SB_${<<parameters.sandbox-id-variable>>}_SHORTCUT_${var}=$link" >> $BASH_ENV
120- var=$((var+1))
121- done
0 commit comments