【问题标题】:Bitbucket pipelines environment variables to trigger-pipeline stepBitbucket 管道环境变量以触发管道步骤
【发布时间】:2021-12-10 20:36:43
【问题描述】:

我在将环境变量从一个步骤传递到触发另一个 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"
                  }]

【问题讨论】:

    标签: environment-variables pipeline bitbucket-pipelines step


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2019-12-30
      • 1970-01-01
      • 2019-02-28
      • 2022-10-13
      • 2022-06-27
      • 2017-08-09
      • 2022-07-01
      • 2022-10-17
      • 1970-01-01
      相关资源
      最近更新 更多