【发布时间】:2019-11-26 23:26:20
【问题描述】:
我已将我的 github 存储库与 Google 云构建集成,以便在 github 中的每次提交后自动构建一个 docker 映像。这工作正常,但现在我想在 Docker 映像构建过程之前对代码进行 sonarqube 分析。因此,我已将 sonarqube 部分集成到 cloudbuild.yaml 文件中。但无法运行。
我已按照链接中提供的步骤操作:https://github.com/GoogleCloudPlatform/cloud-builders-community/tree/master/sonarqube
并将声纳扫描仪图像推送到谷歌容器注册表中。 我的 sonarqube 服务器在 GCP 实例上运行。在 github 中的每次提交时,cluod build 都会自动触发并开始执行 cloudbuild.yaml 文件中提到的任务
Dockerfile:
FROM nginx
COPY ./ /usr/share/nginx/html
cloudbuild.yaml:
steps:
- name: 'gcr.io/PROJECT_ID/sonar-scanner:latest'
args:
- '-Dsonar.host.url=sonarqube_url'
- '-Dsonar.login=c2a7631a6e402c338739091ffbc30e5e3d66cf19'
- '-Dsonar.projectKey=sample-project'
- '-Dsonar.sources=.'
- name: 'gcr.io/cloud-builders/docker'
args: [ 'build', '-t', 'gcr.io/PROJECT_ID/html-css-website', '.' ]
images:
- 'gcr.io/PROJECT_ID/html-css-website'
错误:
Status: Build failed
Status detail: failed unmarshalling build config cloudbuild.yaml: yaml: line 3: did not find expected key
【问题讨论】:
-
请将您的 YAML 内容用适当的格式标记括起来:该错误表明您的 YAML 错误,但以当前格式无法读取。
-
感谢@mc1arke,格式正确。这只是在这里输入问题。这里 PROJECT_ID 表示我的实际 GCP 项目 ID,sonarqube_url 表示我的 sonarqube 实例的实际 url