PREQ-5738: Adds maven-style project key extraction to check-sca#255
Conversation
4cd197a to
51eb5cb
Compare
SummaryThis PR enhances the
The PR also removes "Required" from the workflow name (BUILD-11387) and updates documentation accordingly. All 21 tests pass (16 existing + 5 new). What reviewers should knowWhere to start:
Key things to verify:
Tests cover all paths:
|
There was a problem hiding this comment.
Pull request overview
Adds Maven-style SonarQube project key discovery (groupId:artifactId) to the check-sca action so repositories relying on SonarQube’s Maven-default key derivation can be validated without requiring an explicit <sonar.projectKey> in pom.xml. Also renames the check/workflow display name to remove “Required”.
Changes:
- Extend
discover_project_keys()to emit a Maven-derivedgroupId:artifactIdkey candidate frompom.xml(while still preferring an explicit<sonar.projectKey>). - Add ShellSpec coverage for Maven key derivation scenarios (project-level
groupId, inherited parentgroupId, precedence, and negative case). - Update README + workflow name from “Required SCA Check” to “SCA Check”.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
check-sca/check-sca.sh |
Adds Maven groupId:artifactId extraction logic to project key discovery. |
spec/check-sca_spec.sh |
Adds tests validating the new Maven key extraction behavior. |
README.md |
Updates the documented check name in the example workflow snippet. |
.github/workflows/check-sca.yml |
Renames the workflow to “SCA Check”. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
51eb5cb to
3d3b95a
Compare
3d3b95a to
5b5ad37
Compare
|



Summary
discover_project_keys()to extract Maven-stylegroupId:artifactIdproject keys from
pom.xml, in addition to the existing<sonar.projectKey>property extraction
check-scafailures for repos analyzed on SonarQube Next whoseproject keys follow the Maven default convention (e.g.,
org.sonarsource.plugins.cayc:sonar-cayc-plugin) rather than theSonarSource_<repo-name>conventionContext
Two repos (
sonar-cayc-stats-pluginandsonar-scanner-jenkins) fail thecheck-scaaction because they don't define an explicit<sonar.projectKey>in their pom.xml. SonarQube generates their project keys from Maven coordinates
(
groupId:artifactId), but the action couldn't discover these keys and fellback to the
GITHUB_REPOSITORY-derived key which doesn't match anything.See: PREQ-5738
How it works
After checking for an explicit
<sonar.projectKey>property (step 4a), thescript now also extracts the project-level
<groupId>and<artifactId>frompom.xml (step 4b). It handles:
<groupId>when present<groupId>when theproject doesn't define its own (standard Maven inheritance)
<parent>,<dependencyManagement>,<dependencies>,<build>,<profiles>,<reporting>, and<modules>blocks before extracting, so dependency groupIds aren't matched
Both keys are emitted as candidates (deduplication handles overlap), so the
polling loop tries all of them against all platforms.
Test plan
derives groupId:artifactId from pom.xml with project-level groupId—pom with parent + its own groupId →
org.sonarsource.plugins.cayc:sonar-cayc-pluginderives groupId:artifactId from pom.xml with inherited parent groupId—pom with no project-level groupId →
org.jenkins-ci.plugins:sonarprefers sonar.projectKey over groupId:artifactId from pom.xml—both explicit key and Maven key appear as candidates
does not derive Maven key when pom.xml has only parent block—no project-level artifactId → no key emitted
gh api