簡體   English   中英

Bitbucket 管道環境變量以觸發管道步驟

[英]Bitbucket pipelines environment variables to trigger-pipeline step

我在將 env 變量從一個步驟傳遞到另一個 repo 中觸發另一個管道的步驟時遇到問題。 提取 VERSION 后,我需要觸發另一個管道。

我認為將一些變量從父步驟傳遞到下一步只是一種常見情況,但沒有關於如何做到這一點的信息。 在 atlassian/trigger-pipeline 中,在觸發另一個管道管道示例之前,我無法運行任何腳本步驟:

- 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"
                  }]

我從 Atlassian 社區收到的這個答案

- 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"
               }]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM