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?
@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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.