在 Bitbucket 上启用 PR Decoration,可以通过以下步骤实现。
示例代码:以下是使用 GitLab CI/CD 生成代码质量报告,并将其上传到 Bitbucket 仓库中的示例。
image: maven:3-jdk-8
variables:
MAVEN_OPTS: "-Dmaven.repo.local=./.m2/repository"
cache:
paths:
- .m2/repository/
stages:
- build
- test
- quality
build:
stage: build
script:
- mvn clean compile
test:
stage: test
script:
- mvn test
quality:
stage: quality
script:
- mvn sonar:sonar -Dsonar.host.url= -Dsonar.login= -Dsonar.projectKey=
在上述示例中,我们使用 Maven 构建和测试 Java 代码,并使用 SonarQube 进行代码质量分析。最后,我们可以在 SonarQube 仪表板上查看代码质量情况并上传报告到 Bitbucket 仓库中。