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

How tu use BITBUCKET_PIPE_SHARED_STORAGE_DIR variable ?

Gaël Brochard September 13, 2023

hello,

 

I am triggering a pipeline from one repo to another one ( in bitbucket cloud) and I would like to pass the BITBUCKET_TAG value from the source pipeline. 

I tried several solution and also tried using BITBUCKET_PIPE_SHARED_STORAGE_DIR variable but nothing work.

I followed this article: https://support.atlassian.com/bitbucket-cloud/docs/advanced-techniques-for-writing-pipes/

But it is not clear to me how to use this solution.

Could you help me ?

 

Regards,

 

1 answer

1 vote
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 14, 2023

Hello @Gaël Brochard and welcome to the Community!

Just to bring some context, when you start a pipeline a build container will be span up where your script will run. When you invoke a pipe in your script, a separate container is created where the pipe is executed, and a shared storage between the pipe's container and the build container is created, which is the variable BITBUCKET_PIPE_SHARED_STORAGE_DIR. This shared storage can only be used to pass files from the pipe's to the build container and/or to other pipes in the same step. It's not possible to share the content of that directory with a second pipeline.

With that in mind, per your description, I assume you are using the atlassian/trigger-pipeline pipe, which provides the optional variable PIPELINE_VARIABLES where you can pass a JSON file containing all the variables you want to pass to the external pipeline being triggered. You can use this pipe variable to pass the first repository's BITBUCKET_TAG to the second repository's pipeline. Following is an example of using that variable : 

script:
  - pipe: atlassian/trigger-pipeline:5.3.0
    variables:
      BITBUCKET_USERNAME: $BITBUCKET_USERNAME
      BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
      REPOSITORY: 'your-awesome-repo'
      REF_TYPE: 'branch'
      REF_NAME: 'master'
      CUSTOM_PIPELINE_NAME: 'secondrepo-pipeline'
      PIPELINE_VARIABLES: >
          [{
            "key": "BITBUCKET_EXPORTED_TAG",
            "value": "$BITBUCKET_TAG"
          }]
      WAIT: 'true'

In this example, we are exporting the variable BITBUCKET_TAG from the first pipeline to a variable named BITBUCKET_EXPORTED_TAG on the second pipeline.

It's important to note that passing variables is only currently available for custom-triggered pipelines, so make sure the pipeline in the second repository is defined as custom so you are able to pass the variables.

Hope that helps! Let me know in case you have any questions.

Thank you, @Gaël Brochard !

Patrik S

Suggest an answer

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

Atlassian Community Events