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

Create a _new_ pipeline variable

I have successfully modified pipeline variables with the API. Now I am trying to create a new pipeline variable using the API.

According to the documentation you should be able to create a new one using /2.0/repositories/{workspace}/{repo_slug}/pipelines_config/variables/

The "request example" shows the inclusion of a pipeline variable uuid but since the variable does not exist, I do not have a uuid.  

$ echo $request_body
{ "key": "test", "value": "setMe", "secured": "false" }
$ curl -X PUT -u "$BB_API_AUTH" https://api.bitbucket.org/2.0/repositories/workspace/repo/pipelines_config/variables -d "$request_body"
{"type": "error", "error": {"message": "Resource not found", "detail": "There is no API hosted at this URL.\n\nFor information about our API's, please refer to the documentation at: https://developer.atlassian.com/bitbucket/api/2/reference/"}}

I've tried with and without a slash after 'variables'. 

$ curl -X PUT -u "$BB_API_AUTH" https://api.bitbucket.org/2.0/repositories/workspace/repo/pipelines_config/variables/ -d "$request_body"
{"type": "error", "error": {"message": "Method not allowed"}}

How can I create a new pipeline variable?

1 answer

0 votes

 

@Mary Sipple in the second case you're  using right url with / (https://api.bitbucket.org/2.0/repositories/workspace/repo/pipelines_config/variables/) , but somewhy use PUT http method.

PUT method is for existing resource, that means, for existing variable, if you want to change its value, for example.

To create a variable you have to use POST method for that

Regards, Galyna

Of course! Thank you so much. It's working now.

Regards,   Mary

Suggest an answer

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

📣 Calling Bitbucket Data Center customers to participate in research

Hi everyone, Are you Bitbucket DC customer? If so, we'd love to talk to you! Our team wants to dive deep to understand your long-term plans regarding Bitbucket DC and Atlassian Cloud. Do you plan...

117 views 2 4
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