Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

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

How to view the values of secured Repository variables?

Rishabh Srivastava
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 2, 2022

Below is the path of the variable that I'm trying to view:

Repository settings (on left vertical menu) -> Pipelines (submenu) -> Repository variables


Here it contains few secured variables whose values we are trying to fetch, any suggestions/help is appreciated.

 

 

2 answers

1 accepted

2 votes
Answer accepted
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 3, 2022

Hey Rishabh,

Unfortunately - you cannot view these values once they have been set - and these are obscured from the build log if you try to echo these. This is by design as secure variables are stored as encrypted valuesIf you want to edit a secure variable, you can only give it a new value or delete it.

More information regarding this can be found here:
https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/

 

Cheers!

- Ben (Bitbucket Cloud Support)

Rishabh Srivastava
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 3, 2022

Thanks Ben! :)

Marcin Kielar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 11, 2024
script:
- echo "$MY_VERY_SECRET_VARIABLE" | base64

What I find annoying is that there's no way to access these values via REST API, and that their values are invisible for Dynamic Pipelines. :(

1 vote
남성식 March 21, 2023

I tried below and it worked.

- step:

    script:

      - echo $VAR >> var.txt

    artifacts:

      - var.txt

You can see the value on var.txt file.

I‘m curious that secure variables are really secure. It could be exported to a file and this file could be downloaded!

Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 21, 2023

Hey ,

 

I've just tested on my end with a secured variable - the value of the variable is not actually printed, it prints the variable name without the value - do you see the same output?

 - step:

   script:

   - echo $testvar >> var.txt

   - cat var.txt
남성식 March 23, 2023

Oh, you cannot see the value with 'cat', because the bitbucket automatically erase every string, which is same with secured variable.

So you should save it as a artifacts and download it to see the value.

Like Danila Lelyaev likes this
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 23, 2023

Hey 남성식,

You're right actually, I've just tested this on my end.

I've raised a bug ticket - thank you for that, that's a great find:
https://jira.atlassian.com/browse/BCLOUD-22556

Cheers!

- Ben (Bitbucket Cloud Support)

남성식 March 27, 2023

Hey Ben,

As I think, this is the answer for your question: https://community.atlassian.com/t5/Bitbucket-questions/Are-secured-variables-really-secure/qaq-p/2306410#M91721

I was also wondering why these secured variables are viewable to developers, but these developers have already right to read and write this repository.

If you have other tokens, which has more right that just writing and reading the repo, then you should use deployment variable to save it and make that deployment environment to be restricted for admins only. Then developers can not trigger deployment step, so they couldn't download the artifacts which they generated with the script above.

btw. my name is pronounced Sungsik Nam. I'm pretty sure it was a bit(!) hard to pronounce.

Like inger_klekacz likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Upcoming Bitbucket Events