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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Unable to create an environment variable... Edited

Hi all,

I've tried for probably hours to get the below working but I just can't seem to be able to create an environment variable. The API I'm calling is ...

$ curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d '{"key": "mytestkey", "value": "value1", "secured": false }' https://api.bitbucket.org/2.0/repositories/<username>/<repo-slug>/deployments_config/environments/{environment UUID in curly brackets}/variables

The error I get is : 

{"error": {"message": "Not found", "detail": "The value provided is not a valid uuid."}}

The environment UUID I use in the URL is what is returned from a GET on

https://api.bitbucket.org/2.0/repositories/<username>/<repo-slug>/environments/

Can anyone see what I'm doing wrong pls (I think I'm following the API docs at : https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/deployments_config/environments/%7Benvironment_uuid%7D/variables ). I'm not sure the API docs are strictly correct on that URL above because I don't know how you can include a UUID in the payload when you're creating a variable. 

 

Many thanks for any help / tips...

 

2 answers

1 accepted

1 vote
Answer accepted

Hi @curtisa ,

You will need to encode the characters for the curly brackets in order for this to work.

{ should be replaced with %7B and } with %7D

An example call:

curl -X POST -H "Content-Type: application/json" -u username:app-password 
-d '{"key": "mytestkey", "value": "value1", "secured": false }' https://api.bitbucket.org/2.0/repositories/my-workspace/my-repo/deployments_config/environments/%7B26e47eac-2770-4b69-8f23-92634d03a443%7D/variables

where 26e47eac-2770-4b69-8f23-92634d03a443 is the UUID of my Pipelines environment.

Could you please give this a try?

Please feel free to let us know if it works or if you need further assistance.

Kind regards,
Theodora

Hi Theodora,

Yes that fixed it many thanks.

Kind regards

Alex

Hi Alex,

That's good to hear, thank you for the update and you are very welcome!

Kind regards,
Theodora

0 votes

Hi! 

How did you get the uuid ? 

Hi,

By calling

https://api.bitbucket.org/2.0/repositories/<username>/<repo-slug>/environments/

and then picking the uuid value of the environment I want to set the variable for, i.e... 

"uuid": "{abcdefg-12345-abcd-1234-abc1234567890}"

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

2,589 views 1 9
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