Bitbucket管道失败说该步骤为空,空或缺失

问题描述 投票:1回答:1

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

我已将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个回答
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
© www.soinside.com 2019 - 2024. All rights reserved.