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

How do I get Deployment variables via REST API?

sajalshres
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!
August 31, 2017

Hello,

I want to extract deployment environment variables via the Rest API.

The URL looks like: https://localhost;8085/bamboo/chain/admin/config/configureChainVariables.action?buildKey={build-key}

I don't see any way for getting these values in BAMBOO REST API documentation.

 

Please help!.

 

Thanks,

Sajal

 

3 answers

1 accepted

2 votes
Answer accepted
Rafael Pinto Sperafico
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.
December 28, 2018

Hi,

If you also agree, I have created a suggestion (https://jira.atlassian.com/browse/BAM-20225 - As an admin, I would like to set up Variables in Bamboo using REST API) for making Bamboo variables available through REST API.

Please, feel free to add comment(s) as well as voting and becoming a watcher, so you can receive latest updates on that request.

sajalshres
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!
April 9, 2019

Thanks, Will do the same.

Like Naveen Goel likes this
Naveen Goel
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!
September 6, 2021

I have also added my comment to provide this feature.

2 votes
rsperafico
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 17, 2018

Hi @sajalshres,

You could run the following action:

# replace USERNAME to authenticate against Bamboo's instance
user must have EDIT permission over given plan
# replace FOO with variable key
# replace BAR with variable value
# replace http://localhost:8085 with Bamboo's Base URL
# replace PROJ-PLAN with planKey in which you want to add plan variables

curl -k -u USERNAME \
     -H 'X-Atlassian-Token: no-check' \
     -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
     -d 'variableKey=FOO&variableValue=BAR&bamboo.successReturnMode=json&confirm=true' \
     -X POST 'http://localhost:8085/build/admin/ajax/createPlanVariable.action?planKey=PROJ-PLAN'

For deployment variables, same thing:

# replace USERNAME to authenticate against Bamboo's instance
  user must have EDIT permission over given plan
# replace FOO with variable key
# replace BAR with variable value
# replace http://localhost:8085 with Bamboo's Base URL
# replace PROJ-PLAN with planKey in which you want to add plan variables
# replace ENVIRONMENT_ID with environment id in which you want to add plan variables

curl -k -u USERNAME \
     -H 'X-Atlassian-Token: no-check' \
     -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
     -d 'variableKey=FOO&variableValue=BAR&bamboo.successReturnMode=json&confirm=true' \
     -X POST 'http://localhost:8085/deploy/config/createEnvironmentVariable.action?environmentId=ENVIRONMENT_ID'

Hope the above helps somehow.

Kind regards,

Rafael

Mike Klecka
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!
November 14, 2018

Is there a way to GET deployment environment variables using the REST API? I think that was the original question and it's still not answered.

Like # people like this
ofiryariv February 12, 2020

Is there a full documentation of the deplo/config API?
e.g. to UPDATE existing variable?
It seems it is done by updateEnvironmentVariable but I do not know how to use it

Venkat Pasula April 24, 2020

@rsperafico ,

As suggested by you I tried the below curl command which is NOT working

 

curl -k -u MyUserId:MYpassword \
-H 'X-Atlassian-Token: no-check' \
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
-d 'variableKey=TESTVAR&variableValue=NEWVALUE&bamboo.successReturnMode=json&confirm=true' \
-X POST 'https://myBamboohost/deploy/config/configureEnvironmentVariables.action?environmentId=123456'


 I also tried "confirm=false" option , even this is not working.

Am I missing something here?

Venkat Pasula April 26, 2020

After 2 days of struggle finally I got it to work. It worked with variableId parameter .

Here is the complete Code

curl -k -u MyUserId:MYpassword \
-H 'X-Atlassian-Token: no-check' \
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
-d 'variableKey=TESTVAR&variableValue=NEWVALUE&bamboo.successReturnMode=json&confirm=true' \
-X POST 'https://myBamboohost/deploy/config/updateEnvironmentVariable.action?environmentId=123456&variableId=XXXXX'
Like # people like this
EH
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!
June 18, 2020

.

Luiz Augusto Lorenson
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!
May 5, 2022

How did you find the variableId ? 

Hien September 18, 2022

It is September 2022. I appreciate that the answer, although indirect, but has been accepted.

Is there an update on how one can consume the REST API to get a list of variables of a deployment project?

Has that been implemented and in which Bamboo version?

1 vote
Daniel Mendes July 17, 2018

yeah would be nice to have a way to get this... im trying to set deployment variables via the REST API and not finding any method to do it.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events