【问题标题】:Bitbucket Pipeline fails saying that step is empty, null or missingBitbucket Pipeline 失败,提示该步骤为空、null 或缺失
【发布时间】:2019-04-14 21:30:52
【问题描述】:

我正在尝试配置 Bitbucket 管道以执行 SonarQube 管道,但 Bitbucket 抱怨管道步骤为空、null 或缺失。

我已将 SONAR_TOKEN 定义为具有正确标记的项目变量。

这是我当前的 bitbucket-pipeline.yml 文件:

image: atlassian/default-image:2

clone:
  depth: full

definitions:
  caches:
    sonar: ~/.sonar/cache
  steps:
    - step: &sonarcloud
      name: Analyze on SonarCloud
      caches:
        - sonar
      script:
        - pipe: sonarsource/sonarcloud-scan:0.1.5
          variables:
            SONAR_TOKEN: ${SONAR_TOKEN}

pipelines:
  branches:
    '*':
      - step: *sonarcloud

有什么想法吗?

【问题讨论】:

    标签: bitbucket bitbucket-pipelines


    【解决方案1】:

    发现问题。

    问题是定义区域中的步骤详细信息缩进不正确,并且缺少一个额外的缩进级别。

    代替:

    ...
    - steps: &sonarcloud
      name: ...
      ...
    

    这是

    ...
    - steps: &sonarcloud
        name: ... // Notice the extra level of indentation
        ...
    

    正确的 YAML 是:

    image: atlassian/default-image:2
    
    clone:
      depth: full
    
    definitions:
      caches:
        sonar: ~/.sonar/cache
      steps:
        - step: &sonarcloud
            name: Analyze on SonarCloud
            caches:
              - sonar
            script:
              - pipe: sonarsource/sonarcloud-scan:0.1.5
                variables:
                  SONAR_TOKEN: ${SONAR_TOKEN}
    
    pipelines:
      branches:
        '*':
          - step: *sonarcloud
    

    【讨论】:

    • 不错的发现!也解决了我的问题:D
    猜你喜欢
    • 1970-01-01
    • 2012-07-20
    • 1970-01-01
    • 2016-09-16
    • 2020-06-13
    • 2020-05-07
    • 1970-01-01
    • 2020-06-15
    • 1970-01-01
    相关资源
    最近更新 更多