我正在尝试配置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
有什么想法吗?
答案 0 :(得分: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