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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

variable could assign in the script

Stan Zhou I'm New Here Jul 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

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 Jul 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
Community showcase
Published in Bamboo

Bamboo Data Center Apps Program coming soon

G’day Bamboo customers, As we approach GA for Bamboo Data Center , we would like to inform you that the Data Center Apps Program for Bamboo starts this quarter. How long does it take? We are g...

83 views 0 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you