And.Dzh
And.Dzh

Reputation: 45

Bitbucket pipelines environment variables to trigger-pipeline step

I have a problem with pass env variable from one step, to a step that triggers another pipeline in another repo . After extracting VERSION I need to trigger another pipeline.

I think it's just a common case to pass some variable from parent step to next step, but no information on how to do it . In atlassian/trigger-pipeline I can't run any script steps before I trigger another pipeline pipeline example:

- step:
        name: upload to test
        image: 
            name: ci:latest
        script:
          - bin=`ls  | grep .bin`
          - export VERSION=${bin%.*}
          - aws s3 sync . s3://somebacketname/test/
          
- step:
      name: testing 
      trigger: manual
      script:
        - pipe: atlassian/trigger-pipeline:4.1.5
          variables:
            BITBUCKET_USERNAME: $USER
            BITBUCKET_APP_PASSWORD: $PASSWORD
            REPOSITORY: 'test'
            BRANCH_NAME: 'master'
            CUSTOM_PIPELINE_NAME: 'critical-test'
            WAIT: 'true'
            PIPELINE_VARIABLES: >
                  [{
                    "key": "DESIRED_VERSION",
                    "value": "$VERSION"
                  },
                  {
                    "key": "DURATION",
                    "value": "15"
                  }]

Upvotes: 0

Views: 2721

Answers (1)

And.Dzh
And.Dzh

Reputation: 45

This answer I received from the Atlassian community

- step:
    name: upload to test
    image: 
    name: ci:latest
    script:
      - bin=`ls | grep .bin`
      - echo export VERSION=${bin%.*} >> build.env
      - aws s3 sync . s3://somebacketname/test/
    artifacts:
      - build.env 
- step:
    name: testing 
    trigger: manual
    script:
      - source build.env
      - pipe: atlassian/trigger-pipeline:4.1.5
        variables:
          BITBUCKET_USERNAME: $USER
          BITBUCKET_APP_PASSWORD: $PASSWORD
          REPOSITORY: 'test'
          BRANCH_NAME: 'master'
          CUSTOM_PIPELINE_NAME: 'critical-test'
          WAIT: 'true'
          PIPELINE_VARIABLES: >
              [{
                "key": "DESIRED_VERSION",
                "value": "$VERSION"
               },
               {
                "key": "DURATION",
                "value": "15"
               }]

Upvotes: 1

Related Questions