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

how to inherance or share export VARS to other steps in my bitbucket-pipeline.yaml

Andrés Carrillo
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!
February 23, 2024

how to inherance or share export VARS to other steps in my bitbucket-pipeline.yaml without use artifacts because I need to share confidencial values as AWS credentials among other values.

----------------------------- bitbucket snipped ----------------------------------

pipelines:
  custom:
     database-img:
              - variables:
                    - name: DOCKER_FILE
                      allowed-values:
                           - DockerfileMongo
                           - DockerfileMysql
                      default: DockerfileMongo
                 - name: ENV
                   allowed-values:
                        - POC
                        - DEV
                        - TEST
                        - PRD
                   default: POC
              - step: *set-env
              - step: *ecr-login
              - step: *build-push-image

I need set my AWS credentials in set-env step and share those values to the others steps ecr-login and build-push-image

but I don't want to share those values in an artifact

I tried use inherance but I don't exactly how to implement it.

Thanks in advance for your suggestions or advices

2 answers

1 accepted

0 votes
Answer accepted
Andrés Carrillo
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!
February 26, 2024

Hi Mark, thanks a lot for your suggestion well, what  I did to resolve this situation was to print the definitions in the set_env.sh file like this:

step: &set-env
     name: setting up environment

     echo "export AWS_ACCESS_KEY_ID=\${"${ENV}"_AWS_ACCESS_KEY_ID}" >> set_env.sh
     *
     *
     *
artifacts:
- set_env.sh

results in set_env.sh:

export AWS_ACCESS_KEY_ID=${DEV_AWS_ACCESS_KEY}  --> this one already is defined in my repository variables.

step: &login-aws
   name: login to aws
   
script: |
          source set.env.sh

In this way I pass the values that the script requires without showing them in the set-env.sh file.
1 vote
Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 25, 2024

Hi @Andrés Carrillo,

Welcome to the community.

Unfortunately, Pipelines doesn't have the ability to share/export variables from one step to another at the moment.

We do have an existing feature request for it that can be located through this link. - https://jira.atlassian.com/browse/BCLOUD-20294.
You can upvote and watch it for now so that you'll be notified of any updates from our team when the feature becomes available on Bitbucket Cloud, according to our policy on implementing new features.

Right now, you can use pre-defined secured variables either from your repository or workspace level.

Let me know if you have any questions.

Regards,
Mark C

Suggest an answer

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

Atlassian Community Events