Skip to content

BUILD-10287 Use sonar.scm.revision instead of sonar.analysis.sha1#204

Closed
julien-carsique-sonarsource wants to merge 1 commit intomasterfrom
fix/jcarsique/BUILD-10287-sqScmSha
Closed

BUILD-10287 Use sonar.scm.revision instead of sonar.analysis.sha1#204
julien-carsique-sonarsource wants to merge 1 commit intomasterfrom
fix/jcarsique/BUILD-10287-sqScmSha

Conversation

@julien-carsique-sonarsource
Copy link
Contributor

@julien-carsique-sonarsource julien-carsique-sonarsource commented Feb 3, 2026

BUILD-10287

This PR replaces the obsolete sonar.analysis.sha1 property with sonar.scm.revision across all build-* actions.

Prefer #205 if it works without sonar.scm.revision parameter.

Changes

Property Migration:

  • Removed sonar.analysis.sha1 (obsolete)
  • Added sonar.scm.revision with proper value assignment

Value Logic:

  • For pull requests: sonar.scm.revision=PULL_REQUEST_SHA
  • For other builds: sonar.scm.revision=GITHUB_SHA

Affected Files

Build Scripts:

  • build-maven/build.sh - Added conditional logic for sonar.scm.revision
  • build-gradle/build.sh - Simplified branch-specific logic and migrated property
  • build-npm/build.sh - Migrated from sonar.analysis.sha1 to sonar.scm.revision
  • build-yarn/build.sh - Migrated from sonar.analysis.sha1 to sonar.scm.revision
  • build-poetry/build.sh - Migrated from sonar.analysis.sha1 to sonar.scm.revision

Test Coverage:

  • Updated all spec files to verify sonar.scm.revision is used correctly
  • Added specific test cases for PULL_REQUEST_SHA usage in PR scenarios

Tests

@hashicorp-vault-sonar-prod
Copy link

hashicorp-vault-sonar-prod bot commented Feb 3, 2026

BUILD-10287

Replace the obsolete sonar.analysis.sha1 property with sonar.scm.revision across all build-* actions (maven, gradle, npm, yarn, poetry).

The value is set to PULL_REQUEST_SHA for pull requests, and falls back to GITHUB_SHA for other builds.

Changes:
- build-maven: Added sonar.scm.revision with conditional logic
- build-gradle: Simplified branch-specific logic and use sonar.scm.revision
- build-npm: Changed from sonar.analysis.sha1 to sonar.scm.revision
- build-yarn: Changed from sonar.analysis.sha1 to sonar.scm.revision
- build-poetry: Changed from sonar.analysis.sha1 to sonar.scm.revision

Tests:
- Updated all spec files to verify sonar.scm.revision is used
- Added specific tests for PULL_REQUEST_SHA usage in PR scenarios
@julien-carsique-sonarsource julien-carsique-sonarsource force-pushed the fix/jcarsique/BUILD-10287-sqScmSha branch from 2294a8e to 1df28d9 Compare February 3, 2026 18:06
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 3, 2026

SonarQube reviewer guide

Review in SonarQube

Summary: Standardize Sonar analysis by using pull request base SHA instead of commit SHA for PR analysis across all build systems (Gradle, Maven, npm, Poetry, Yarn).

Review Focus:

  • Verify PULL_REQUEST_SHA is consistently sourced from github.event.pull_request.base.sha (only added to Yarn action.yml—check if other systems need this)
  • Ensure the parameter name change from -Dsonar.analysis.sha1 to -Dsonar.scm.revision is correct per Sonar's API
  • Watch for edge cases: parameter validation using ${PULL_REQUEST_SHA:?} in some files but not others (build-gradle uses it, build-poetry doesn't)
  • Verify Gradle's simplified branch logic doesn't lose functionality (removed explicit branch-specific arguments)

Start review at: build-gradle/build.sh. It contains the most significant refactor—consolidating multiple branch conditions into a cleaner if/else structure—and serves as the reference implementation for how the other build systems should follow.

💬 Please send your feedback

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues
0 Dependency risks

Measures
0 Security Hotspots
100.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@julien-carsique-sonarsource
Copy link
Contributor Author

Superseded by #205

@julien-carsique-sonarsource julien-carsique-sonarsource deleted the fix/jcarsique/BUILD-10287-sqScmSha branch February 4, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant