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

Is it possible to share variables between two different pipelines?

Valéria Bezerra dos Santos
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!
October 5, 2023

I have a development pipeline that triggers a QA pipeline. In this development pipeline, it is possible to deploy in 3 different environments.

And after each deployment, the testing pipeline is triggered. But just as deployment occurs automatically in each branch, I wanted the test pipeline to know in which environment it should run automatically. So I thought, is it possible to share values ​​between two different pipelines, so that, for example, if I run the deployment in the DEV environment when triggering the test pipeline, it sets the value 1 in the environment without needing me to intervene manually?

1 answer

1 accepted

0 votes
Answer accepted
Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 9, 2023

Hi @Valéria Bezerra dos Santos,

Welcome to the community.

It is not possible to directly share variables from one Pipelines build to another.
However, you can try to leverage this existing Pipes script called atlassian/trigger-pipeline which will allow you to trigger a custom Pipelines build and pass variables.

Here's an example:

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: 'deployment-pipeline'
      PIPELINE_VARIABLES: >
          [{
            "key": "AWS_DEFAULT_REGION",
            "value": "us-west-1"
          },
          {
            "key": "AWS_ACCESS_KEY_ID",
            "value": "$AWS_ACCESS_KEY_ID",
            "secured": true
          },
          {
            "key": "AWS_SECRET_ACCESS_KEY",
            "value": "$AWS_SECRET_ACCESS_KEY",
            "secured": true
          }]
      WAIT: 'true'

Regards,
Mark C

Valéria Bezerra dos Santos
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!
October 10, 2023
Hello,@Mark C

Thank you very much for getting back to me.

I managed to solve it yesterday and precisely with a similar code that I found in this article:


I did it like this:

Dev pipeline "sending":

PIPELINE_VARIABLES: >

[ {

"key": "TEST_VARIAVEL",

"value": "1"

}]

- echo $TEST_VARIAVEL


QA Pipeline “Getting the value of the variable”:


- cucumber -t @requests $FEATURE TEST_ENV=$TEST_VARIAVEL

It worked, the QA pipeline was able to point out that the environment value was = 1, and the test ran without needing me to interfere with the flow.
03.PNG

Thank you very much, again.
Like Mark C likes this
Mark C
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 12, 2023

Great, glad to know it worked for you.

Regards,
Mark C

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events