使用 bitrise 进行拉取请求的 Sonarcloud 代码覆盖率

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

我有 iOS 项目,对于主分支工作正常,但对于拉取请求,我看到

0 New Lines
。我有这个 bitrise 步骤用于拉取请求:

$BITRISE_SOURCE_DIR/xccov-to-sonarqube-generic.sh $BITRISE_XCRESULT_PATH > Coverage.xml

sonar-scanner -Dsonar.projectKey={porjectKey} \
-Dsonar.organization={projectOrgatization} \
-Dsonar.pullrequest.base=$BITRISEIO_GIT_BRANCH_DEST \
-Dsonar.pullrequest.branch=$BITRISE_GIT_BRANCH \
-Dsonar.pullrequest.key=$PULL_REQUEST_ID \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.coverageReportPaths=Coverage.xml \
-Dsonar.language=swift \
-Dsonar.sources=App,ImageShare \
-Dsonar.tests=Tests \
-Dsonar.c.file.suffixes=- \
-Dsonar.cpp.file.suffixes=- \
-Dsonar.objc.file.suffixes=- \

这是来自声纳扫描仪的日志:

INFO: Scanner configuration file: /opt/homebrew/Cellar/sonar-scanner/5.0.1.3006/libexec/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarScanner 5.0.1.3006
INFO: Java 20.0.2 Homebrew (64-bit)
INFO: Mac OS X 13.5 aarch64
INFO: User cache: /Users/vagrant/.sonar/cache
INFO: Analyzing on SonarCloud
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Load global settings
INFO: Load global settings (done) | time=268ms
INFO: Server id: 1BD809FA-AWHW8ct9-T_TB3XqouNu
INFO: User cache: /Users/vagrant/.sonar/cache
INFO: Loading required plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=586ms
INFO: Load/download plugins
INFO: Load/download plugins (done) | time=819ms
INFO: Found an active CI vendor: 'Bitrise'
INFO: Load project settings for component key: 'ProjectKey'
INFO: Load project settings for component key: 'ProjectKey' (done) | time=216ms
INFO: Process project properties
INFO: Project key: ProjectKey
INFO: Base dir: /Users/vagrant/git
INFO: Working dir: /Users/vagrant/git/.scannerwork
INFO: Load project branches
INFO: Load project branches (done) | time=235ms
INFO: Check ALM binding of project 'ProjectKey'
INFO: Detected project binding: BOUND
INFO: Check ALM binding of project 'ProjectKey' (done) | time=231ms
INFO: Load project pull requests
INFO: Load project pull requests (done) | time=553ms
INFO: Load branch configuration
INFO: Load branch configuration (done) | time=1ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=284ms
INFO: Load active rules
INFO: Load active rules (done) | time=12355ms
INFO: Organization key: OrganizationKey
INFO: Branch name: test-coverage, type: short-lived
INFO: Preprocessing files...
INFO: 2 languages detected in 1341 preprocessed files
INFO: 0 files ignored because of inclusion/exclusion patterns
INFO: 574 files ignored because of scm ignore settings
INFO: Loading plugins for detected languages
INFO: Load/download plugins
INFO: Load/download plugins (done) | time=32ms
INFO: Load project repositories
INFO: Load project repositories (done) | time=1005ms
INFO: SCM collecting changed files in the branch
INFO: SCM collecting changed files in the branch (done) | time=226ms
INFO: Indexing files...
INFO: Project configuration:
INFO:   Excluded sources: **/build-wrapper-dump.json
INFO:   Excluded sources for duplication: Tests
INFO: 1341 files indexed
INFO: Quality profile for json: Sonar way
INFO: Quality profile for swift: Sonar way
INFO: ------------- Run sensors on module ProjectKey
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=205ms
INFO: Sensor cache enabled
INFO: Load sensor cache
INFO: Load sensor cache (19 KB) | time=1394ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=0ms
INFO: Sensor IaC CloudFormation Sensor [iac]
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC CloudFormation Sensor [iac] (done) | time=87ms
INFO: Sensor IaC AzureResourceManager Sensor [iac]
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC AzureResourceManager Sensor [iac] (done) | time=61ms
INFO: Sensor TextAndSecretsSensor [text]
INFO: 954 source files to be analyzed
INFO: 954/954 source files have been analyzed
INFO: Sensor TextAndSecretsSensor [text] (done) | time=3058ms
INFO: Sensor Swift Code Quality and Security [swift]
INFO: 590 source files to be analyzed
INFO: 590/590 source files have been analyzed
INFO: Sensor Swift Code Quality and Security [swift] (done) | time=8211ms
INFO: Sensor IaC Docker Sensor [iac]
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC Docker Sensor [iac] (done) | time=24ms
INFO: Sensor Generic Coverage Report
INFO: Parsing /Users/vagrant/git/cov.xml
INFO: Imported coverage data for 494 files
INFO: Sensor Generic Coverage Report (done) | time=265ms
INFO: ------------- Run sensors on project
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=11ms
INFO: CPD Executor 127 files had no CPD blocks
INFO: CPD Executor Calculating CPD for 463 files
INFO: CPD Executor CPD calculation finished (done) | time=70ms
INFO: SCM writing changed lines
INFO: SCM writing changed lines (done) | time=15ms
INFO: Analysis report generated in 242ms, dir size=734 KB
INFO: Analysis report compressed in 456ms, zip size=613 KB
INFO: Analysis report uploaded in 1437ms
INFO: ANALYSIS SUCCESSFUL, you can find the results at: https://sonarcloud.io/dashboard?id=ProjectKey&branch=test-coverage&resolved=false
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at https://sonarcloud.io/api/ce/task?id=taskId
INFO: Analysis total time: 36.084 s

当我点击此链接https://sonarcloud.io/api/ce/task?id=taskId时,我收到:

{"errors":[{"msg":"Project doesn\u0027t exist"}]}

我做错了什么?

ios swift code-coverage sonarcloud bitrise
1个回答
0
投票

我找到了解决方案在这里

  1. “git-clone”步骤默认将 src 分支头提交合并到 master 中,我可以对其进行参数化并跳过该步骤。
  2. 当我在“git-clone”步骤上禁用合并时,该步骤甚至没有拉下主节点。因此,我添加了一个额外的脚本步骤,以在“git-clone”步骤之后拉下“master”分支。

在声纳扫描仪步骤之前我还有一个额外的步骤:

- [email protected]:
inputs:
- commit: ''
- tag: ''
- branch: "$BITRISEIO_GIT_BRANCH_DEST"
- branch_dest: ''
- pull_request_id: ''
- pull_request_repository_url: ''
- pull_request_merge_branch: ''
- merge_pr: 'no'
- pull_request_head_branch: ''
title: Git Clone Repository ($BITRISEIO_GIT_BRANCH_DEST)
© www.soinside.com 2019 - 2024. All rights reserved.