【问题标题】:Why is my bitbucket-pipelines.yml invalid for pull-request script为什么我的 bitbucket-pipelines.yml 对拉取请求脚本无效
【发布时间】:2019-10-02 22:30:59
【问题描述】:

我有一个用于我正在进行的项目的 bitbucket 管道 yaml 文件。当它设置为在推送时运行时,我让它运行管道正常,但由于我将其切换为在拉取请求上运行,我得到一个无效的 yml 错误。

我找到了如何配置文件的描述:https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html

validator 中,我在第一步出现错误,上面写着Expected a string but found a mapping

当我通过拉取请求运行它时,我收到以下错误:

Configuration error
There is an error in your bitbucket-pipelines.yml at [pipelines > pull-requests]. 
To be precise: This section should be a map (it is currently defined as a list).

我不确定如何修复它,因为它似乎与示例匹配。

下面是我的 yml 文件

image: node:8.10
pipelines:
  pull-requests:
    - step: 
        name: Push repo to CodeCommit
        script:
          - echo $CodeCommitKey > ~/.ssh/codecommit_rsa.tmp
          - base64 -di ~/.ssh/codecommit_rsa.tmp > ~/.ssh/codecommit_rsa
          - chmod 400 ~/.ssh/codecommit_rsa
          - echo $CodeCommitConfig > ~/.ssh/config.tmp
          - base64 -di ~/.ssh/config.tmp > ~/.ssh/config
          - set +e
          - ssh -o StrictHostKeyChecking=no $CodeCommitHost
          - set -e
          - git remote add codecommit ssh://$CodeCommitRepo
          - git push codecommit $BITBUCKET_BRANCH
    - step:
        name: Test and Build
        caches:
          - node
        script: 
          - npm install --no-package-lock
          - npm run test
    - step:
        name: Deploy Serverless
        script:
          - npm i serverless -g
          - npm run deploy

【问题讨论】:

    标签: continuous-integration bitbucket bitbucket-pipelines


    【解决方案1】:

    事实证明,我认为只是评论,仔细检查后是文件的必要部分。只需确保正确缩进(空格)即可。

    image: node:8.10
    pipelines:
      pull-requests:
        '**':
          - step: 
              name: Push repo to CodeCommit
              script:
                - echo $CodeCommitKey > ~/.ssh/codecommit_rsa.tmp
                - base64 -di ~/.ssh/codecommit_rsa.tmp > ~/.ssh/codecommit_rsa
                - chmod 400 ~/.ssh/codecommit_rsa
                - echo $CodeCommitConfig > ~/.ssh/config.tmp
                - base64 -di ~/.ssh/config.tmp > ~/.ssh/config
                - set +e
                - ssh -o StrictHostKeyChecking=no $CodeCommitHost
                - set -e
                - git remote add codecommit ssh://$CodeCommitRepo
                - git push codecommit $BITBUCKET_BRANCH
          - step:
              name: Test and Build
              caches:
                - node
              script: 
                - npm install --no-package-lock
                - npm run test
          - step:
              name: Deploy Serverless
              script:
                - npm i serverless -g
                - npm run deploy
    

    【讨论】:

    • 我也被他们documentation的这一部分搞糊涂了。如果没有明确写入,似乎** 应该是隐含的默认值
    猜你喜欢
    • 1970-01-01
    • 2019-05-25
    • 1970-01-01
    • 2019-10-19
    • 2018-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-22
    相关资源
    最近更新 更多