我正在尝试配置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
有任何想法吗?
发现了这个问题。
问题是定义区域中的步骤详细信息缩进不正确,并且缺少一个额外的缩进级别。
代替:
...
- 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