Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

variable could assign in the script

Stan Zhou
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 19, 2021

The bamboo deploy tasks:

variable name downtime_id 

value null

script

interpreter:shell

script location: inline

#!/usr/bin/env bash
start=$(date +%s)
end=$(date -d "+1 day" +%s)

echo $start
echo $end
echo ${bamboo.local_deploy_environment}
echo ${bamboo.DD_API_KEY_PASSWORD}
echo ${bamboo.DD_APP_KEY_PASSWORD}
echo ${bamboo.downtime_id}

{bamboo.downtime_id}=`curl --silent -X POST "https://api.datadoghq.eu/api/v1/downtime" \
-H "Content-type: application/json" \
-H "DD-API-KEY: ${bamboo.DD_API_KEY_PASSWORD}" \
-H "DD-APPLICATION-KEY: ${bamboo.DD_APP_KEY_PASSWORD}" \
-d '{"scope": "environment-name:${bamboo.local_deploy_environment}","start":'"${start}"',"end":'"${end}"'}'| awk -F, '{print $19}'|awk -F: '{print $2}'`

echo ${bamboo.downtime_id}

 

got error message when deploy: bamboo.downtime_id=50005497: command not found

build 19-Jul-2021 06:35:17 1626676517 2build 19-Jul-2021 06:35:17 1626762917 3build 19-Jul-2021 06:35:17 devops-test 4build 19-Jul-2021 06:35:17 ******** 5build 19-Jul-2021 06:35:17 ******** 6build 19-Jul-2021 06:35:17 1234 7error 19-Jul-2021 06:35:17 /home/bamboo/bamboo-agent-home/temp/9437185-231637028-269254920-ScriptBuildTask-88981604564562628.sh: line 15: bamboo.downtime_id=50005497: command not found 8build 19-Jul-2021 06:35:17 .downtime_id

 

1 answer

0 votes
Cristiano Mariano
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 21, 2021

Hi @Stan Zhou ! Welcome to the community!

It seems to me that you would not need to have curly braces around bamboo.downtime_id when setting its value. Please make a test using it this way:

bamboo.downtime_id=`curl...

 Hope this helps!

Stan Zhou
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 22, 2021

Hi @Cristiano Mariano , thank you for your reply.

I know, the normal way access the variable without curly braces, had tried before it failed.

 

The way to solve the issue is using the Jinject Bamboo variables plugin.

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events