It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

how to use the variable send through a trigger bitbucket pipeline in the triggered pipeline? 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

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

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

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
Community showcase
Published in Bitbucket Pipelines

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

1,044 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you