Skip to content

fix(ci): skip SonarQube scan for dependabot-triggered PRs - #202

Closed
syed-awsaf-informed wants to merge 1 commit into
developfrom
fix/sonar-skip-dependabot
Closed

fix(ci): skip SonarQube scan for dependabot-triggered PRs#202
syed-awsaf-informed wants to merge 1 commit into
developfrom
fix/sonar-skip-dependabot

Conversation

@syed-awsaf-informed

Copy link
Copy Markdown
Contributor

GitHub does not pass repository/org secrets to workflow runs triggered by a Dependabot-authored pull_request event. Since the SonarQube scan step used SONAR_TOKEN_N3, it always failed with "Not authorized or project not found" on Dependabot PRs. This splits the Code Coverage step (which still always runs mvn verify to produce the JaCoCo report) from the SonarQube scan step, and guards the scan step with if: github.actor != 'dependabot[bot]' so it is skipped (not failed) for Dependabot PRs, matching the pattern already used in National-Digital-Twin/ospo-resources' ci.yml.

Copilot AI lite review requested due to automatic review settings August 11, 2026 13:49
@github-actions

Copy link
Copy Markdown
Contributor

✅ OSS Checks Passed

All tracked OSS checks passed in this run.

📊 Total Files 🟢 Passed 🔴 Failed 🧮 Score
14 14 0 100%

Results from commit 8230d8c, view the full job summary↗️ for detailed results.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts the Maven CI workflow so code coverage (JaCoCo generation) still runs on all PRs, while the SonarQube scan is skipped on Dependabot-authored PRs where secrets are not available.

Changes:

  • Split the previous combined mvn verify + sonar invocation into a standalone mvn verify coverage step plus a separate SonarQube scan step.
  • Added an if: github.actor != 'dependabot[bot]' guard so SonarQube scan is skipped (not failed) on Dependabot PRs.
  • Added an explicit check that the JaCoCo XML report exists before attempting the SonarQube scan.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +63 to +66
- name: SonarQube Scan
if: github.actor != 'dependabot[bot]'
env:
GH_PACKAGES_PAT: ${{ secrets.GH_PACKAGES_PAT }}
Comment on lines 57 to 62
- name: Code Coverage
env:
GH_PACKAGES_PAT: ${{ secrets.GH_PACKAGES_PAT }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_N3 }}
run: ./mvnw $MAVEN_CLI_OPTS verify -Dsonar.projectKey=National-Node-Net_federator -Dsonar.organization=national-node-net -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
run: ./mvnw $MAVEN_CLI_OPTS verify
- name: Verify JaCoCo XML exists
run: ls -l target/site/jacoco/jacoco.xml
@sonarqubecloud

Copy link
Copy Markdown

@syed-awsaf-informed
syed-awsaf-informed deleted the fix/sonar-skip-dependabot branch August 11, 2026 16:53
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.

2 participants