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

Create a _new_ pipeline variable

Mary Sipple April 30, 2021

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
Halyna Berezovska
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 7, 2021

 

@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

Mary Sipple May 7, 2021

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

Regards,   Mary

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events