1

I'm unable to successfully update a repository variable and not sure why it's not working.

I've been able to get all the necessary IDs through the API and am making the following curl request:

curl -X PUT "https://api.bitbucket.org/2.0/repositories/{workspace}/{repository}/pipelines_config/variables/{variable_uuid}" -H 'Content-Type: application/json' -d '{"value":"{value}","key":"{name}"}'

From this I get:

{"type": "error", "error": {"message": "Resource not found"}}

Does anyone have any ideas what's missing as I've tried changing everything I can think of but with no luck

WillBV
  • 61
  • 4
  • Did you get it fixed? I receive the same error. I found this in Bitbucket Forum: https://community.atlassian.com/t5/Bitbucket-questions/Update-Pipeline-Variable/qaq-p/1773141 but, no successful – rmsys Dec 22 '21 at 16:48

2 Answers2

0
- curl -v -X PUT "https://api.bitbucket.org/2.0/repositories/$ORG_OR_WORKSPACE/$REPO/pipelines_config/variables/\{$HASH_VARIABLE\}" -H "Content-Type:application/json" -d "{\"key\":\"$VARIABLE_NAME\", \"value\":\"$VARIABLE_VALUE\" }" --user $PIPELINE_APP_PASS

The actual hash needs to be encased in brackets {} which are escaped with \

Try running the command from terminal to make sure you can update your variable. You might want to create a user app password with access, should be username:password

Chase Fenske
  • 128
  • 7
0

Found it

#!/bin/bash

set -x

export USER_NAME=user_name
export PASSWORD=password

curl --user "$USER_NAME":"$PASSWORD" 'https://api.bitbucket.org/2.0/repositories/{user_name}/{application}/pipelines_config/variables/' -H 'Content-Type: application/json'

curl -vX PUT -u "$USER_NAME":"$PASSWORD" --url 'https://api.bitbucket.org/2.0/repositories/{user_name}/{application}/pipelines_config/variables/%7B21212121-2d1e-201a-21c2-212121a21212%7D' -H 'Content-Type:application/json' -d "{\"value\":\"new_value\", \"key\":\"variable\"}"

https://community.atlassian.com/t5/Bitbucket-questions/How-to-get-variable-uuid/qaq-p/1496735

rmsys
  • 931
  • 13
  • 18