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

Override repository variable in pipeline




I have repository variable with name SCRATCH_TO_DELETE. How i can override his value during pipeline execution? I need to use updated value in another pipeline like argument. Thank u

2 answers

1 accepted

1 vote
Answer accepted

Hi Mikhail and welcome to the community!

You can override the value of a repository variable during the build, if the variable's name is SCRATCH_TO_DELETE you can add a command like the following in your yml file:

SCRATCH_TO_DELETE="another value"

Could you please give some more info on your use case regarding using it in another pipeline? Are you triggering another pipeline from your build with the pipe and need to use the updated value there? Or are you doing something different?

It would be useful to have some more info to see if this is going to work for you, or if there is another way of achieving what you want. If you change the value of a repo variable during the build, this modified value will apply only for the step where you are making this change.

Kind regards,


Thanks for the answer. But this is not what I want. I need that after some command, I see the already changed ("another value 1") value in the repository variables



Hi Mikhail,

Thank you for your reply.

This is possible with an API call during the build. I'm not sure how familiar you are with our API, so I'll add detailed instructions:

First, generate an app password for your Bitbucket account by going to your avatar (bottom left corner) > Personal settings > App passwords.

For Permissions, you can select only Pipelines Read, Write, Edit variables.

Go to the Repository settings > Repository variables and create two variables for your Bitbucket username and the app password, named e.g. Bitbucket_Username and Bitbucket_App_Password

Make sure that the one for the app password is secured.

Run a curl command like the following from your machine to get the UUID of the variable you want to edit:

curl -X GET -u Bitbucket_Username:Bitbucket_App_Password<workspace-id>/<repo-slug>/pipelines_config/variables/

replace Bitbucket_Username, Bitbucket_App_Password, <workspace-id>, <repo-slug> in the call with the appropriate values

The output will give you info for all repository variables, take note in the output the UUID of the specific variable you are interested in, let's say it is


4. You can then add an API call like the following in your yml file to change the value of this variable during the build:

curl -X PUT -u ${Bitbucket_Username}:${Bitbucket_App_Password}<workspace-id>/<repo-slug>/pipelines_config/variables/%7B9tf745d2-9566-23e7-c3b5-u012db07092e%7D --header "Content-Type:application/json" --data '{"value":"another value"}'

Please note that the curly brackets of the UUID are encoded in the URL above in order for this to work, { is replaced with %7B and } with %7D

One more thing:
After you run a build with such an API call, you'll be able to see the updated value in Repository settings > Repository variables.
Please note though that this updated value will be applicable in subsequent steps and subsequent builds.
For the step where you are running this API call, the variable will still have the old value, even after the API call, as this was initialised when the step started.
If you want the updated value during the step where you run the API call as well, you can add an additional command after the API call

SCRATCH_TO_DELETE="another value"

 If you want to check more info on the API endpoints I mentioned, you can find it here:

I hope this helps, please feel free to let me know if you have any questions.

Kind regards,



Thank you very much, its a good solution!

Like Theodora Boudale likes this

Good to hear, you're very welcome!

Like Mikhail Sapozhnikov likes this

Capture.PNGHi   @Theodora Boudale,

After doing till the step 3. it doesn't show all the variables (image in attach)

before i used curl -s -X GET -H Bitbucket_Username:Bitbucket_App_Password

and it worked but now recive an error {"type": "error", "error": {"message": "Resource not found"}}

Can you please help? The idea is to find the COMMIT variable to set with $BITBUCKET_COMMIT so that I can send the delta.


Thank you in advance.

Hugo Costa

Suggest an answer

Log in or Sign up to answer
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...

174 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