Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

how to use the variable send through a trigger bitbucket pipeline in the triggered pipeline?

Marine Chaput
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 8, 2019 edited

Hi,

 I am trying to trigger a pipeline in my doc repository when a release is done in my actual code repository. For this, I am following the example given in "trigger bitbucket pipeline".

What I don't understand is how to write the pipeline which will be triggered in the other side and how use the variable send by the release pipeline ?

 

Thank you

 

1 answer

0 votes
Alexander Zhukov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 10, 2019

You're variables will be available in your triggered pipeline as environment variables. For example, if you write your release pipeline like the following:

script:
  - pipe: atlassian/trigger-pipeline:4.0.5
    variables:
      BITBUCKET_USERNAME: $BITBUCKET_USERNAME
      BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
      REPOSITORY: 'your-awesome-repo'
      BRANCH_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'

You can use AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_DEFAULT_REGION in your downstream pipeline like this:

pipelines:
default:
- step:
script:
- echo $AWS_ACCESS_KEY_ID
- echo $AWS_SECRET_ACCESS_KEY
- echo $AWS_DEFAULT_REGION
Marine Chaput
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, 2019

Thank you. I was thinking by putting the custom pipeline name as 'deployment-pipeline, i need to have a downstream pipeline like this : 

pipelines:
custom:
deployment-pipeline:
- step:
script:
- echo $AWS_ACCESS_KEY_ID
- echo $AWS_SECRET_ACCESS_KEY
- echo $AWS_DEFAULT_REGION

I have a still an error when the pipeline is triggered.

Do you have an idea what it could be ?

HttpResponseSummary{httpStatusCode=400, httpStatusMessage=Bad Request, bodyAsString={"key":"variable-service.request.validation-error","message":"The request body contains invalid properties","arguments":{"value.required":"Property value is required"}}} (command VARIABLE_SERVICE_CREATE_PIPELINE_VARIABLE, error key='variable-service.request.validation-error')

Thanks you for your answer

Alexander Zhukov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 10, 2019

You're probably missing a variable value. Note, that there are two fields for each variable: key, which is a variable name, and value, which is an actual variable value.

{
    "key": "VariableName",
    "value": "VariableValue"
}

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, mindful member, mindful member badge, atlassian community, community kudos, community giveaway, atlassian swag, community values, empathy and kindness, badge challenge, atlassian learning, community engagement, swag giveaway

Earn a Badge, Win a Prize 🎁

Earning the Mindful Member badge proves you know how to lead with kindness, plus it enters you into a giveaway for exclusive Atlassian swag. Take the quiz, grab the badge, and comment on our announcement article to spread the good vibes!

Start here
AUG Leaders

Atlassian Community Events