Chapter 18Lesson 04~135 minutes

GitHub, GitLab, Azure DevOps, and Bitbucket Integration: Diagnostics, Failure Modes, and Production Practices

Diagnose permission, binding, webhook, credential-leak, provider-semantics, and revocation failures while preserving the original SonarQube and provider evidence.

GitHubGitLabAzure DevOpsBitbucketLeast privilege

Learning objectives

  • Apply the evidence-first diagnostic sequence to provider binding and credential failures.
  • Diagnose excessive scopes, wrong provider semantics, webhook/auth confusion, secret leakage, and expired/revoked credentials.
  • Keep scanner/build/report failures separate from provider API/decoration failures.
  • Preserve first-failure HTTP/provider/CI/SonarQube evidence before retries or credential changes.
  • Repair the smallest failing trust edge without granting administrator access or changing analysis policy.

1. Evidence-first diagnostic sequence

  1. Preserve CI/scanner log, report-task.txt, ceTaskId, Compute Engine response, Quality Gate response, provider response/check state, and exact Git SHA.
  2. Confirm SonarQube Community/Server edition/version, scanner/runtime, integration/provider version, and relevant extension/plugin version.
  3. Confirm project key, binding, provider organization/repository identity, PR/MR key/target, and server base URL.
  4. Confirm which credential is failing: SonarQube analysis token, provider App/PAT/OAuth credential, repository-import token, or CI service connection.
  5. Inspect only metadata: credential owner, scope, installation/repository reach, expiry, revocation status, and secret-store location. Never print the value.
  6. Confirm network/TLS/API endpoint behavior.
  7. Apply the least-destructive correction to that trust edge.
  8. Rerun the smallest equivalent request; do not rerun the entire pipeline when a provider-only call can be tested independently.

2. Failure: personal administrator token used for automation

Symptom: integration works, but a developer leaves or the token is discovered in multiple pipelines. The technical function may be green while governance is red.

Diagnosis: inventory where the token is stored and what repositories/organization resources it can access. Replace it with a dedicated GitHub App, GitLab technical/group token, Azure technical PAT, or Bitbucket OAuth/API identity as appropriate. Verify the replacement before revocation.

3. Failure: organization-wide privileges for one repository

A 403 is not evidence that “admin” is required. Compare the requested API operation with the documented provider permission. For GitHub PR reporting, Checks/Pull Requests read-write are materially different from organization Administration. For Azure, Code read/write is different from Project/Organization administrator. Grant only the documented operation scope.

4. Failure: assuming all providers use identical semantics

Wrong assumption Why it fails Correct evidence
“Every provider should use a GitHub-style app.” GitLab/Azure Sonar integrations are commonly technical-token based. Provider-specific integration docs and credential metadata.
“Every Bitbucket credential is an App password.” App passwords are deprecated; current Cloud import uses API token and current OAuth UI uses Client terminology. Bitbucket/Sonar current UI, patch level, API token scopes.
“Webhook received means decoration is authorized.” Inbound event and outbound API write are different directions. Provider API response/check ID.
“Pipeline scanner token can publish PR status.” SONAR_TOKEN authenticates to SonarQube, not provider. Separate provider app/PAT/OAuth identity.

5. Failure: webhook confused with analysis authentication

If a webhook callback returns 200 but scanner upload returns 401, the webhook is irrelevant to scanner authentication. Inspect SONAR_TOKEN, project execute-analysis permission, server URL, and token revocation. Conversely, if scanner/CE/gate succeed but provider decoration is absent, inspect provider binding/credential/API delivery—not the scanner token.

6. Failure: provider secret exposed in YAML or logs

Security-sensitive incident. If a real PAT/client secret/private key is committed or printed, stop using it. Preserve only non-secret incident evidence (commit identifier, log location, credential ID/name), revoke/rotate the credential at the provider, remove the value from active configuration, and follow your organization’s secret-exposure process. Do not reproduce the secret in the remediation ticket.

Rewriting Git history may be appropriate under your repository governance, but revocation comes first; history rewriting does not invalidate a credential.

7. Failure: Bitbucket Cloud OAuth setup follows stale labels

Symptom: the runbook says “Create OAuth Consumer / OAuth Key,” but Bitbucket Cloud only offers an OAuth Client / Client ID. Sonar staff acknowledged this documentation/UI mismatch in August 2026 and advised Client credentials with Pull requests Read. Older maintained Sonar lines also required specific patch levels after Bitbucket changed an OAuth response field.

Repair: record current Bitbucket and SonarQube versions, use the current OAuth Client model, and upgrade to a current patch if the server line contains a known compatibility defect. Do not weaken OAuth/TLS or switch to an administrator App password.

8. Failure: Azure PAT expires or technical account becomes invalid

Azure PAT expiry is expected lifecycle state. A provider 401/403 after months of successful decoration can be a credential-expiry or account-access problem while SonarQube analysis still succeeds. Check PAT metadata and technical-account access type/status, rotate deliberately, test the new PAT, then revoke the old one.

9. Intentionally broken example: gate succeeds, provider permission fails

Use the Lesson 2 simulator with checks=read instead of read_write. Preserve:

  • same Git revision;
  • same scanner log/report-task/ceTaskId;
  • same Compute Engine SUCCESS;
  • same Quality Gate response;
  • SIMULATED_PROVIDER_403 plus the insufficient permission manifest.

This failure proves causality: the provider write contract is broken while analysis state is healthy. The repair restores only the missing provider write permission.

10. Causal failure map

Evidence Likely layer Least-destructive action
Scanner 401 before upload SonarQube analysis auth Check project analysis token/server URL/execute-analysis permission.
CE FAILED SonarQube processing Preserve CE error/server logs; provider integration is downstream.
Gate known, provider 403 Provider authorization/binding Inspect provider identity, repo installation, exact write scope.
Provider 404 / wrong repo Binding/provider identity Verify org/workspace/project/repository slug/ID and project binding.
Provider 401 after credential age Expiry/revocation/account lifecycle Rotate through approved technical identity.
Only CI job failed after gate PASS CI policy/script Inspect runner logic separately from SonarQube/provider state.

11. Production shortcuts to reject

  • Do not grant organization/project administrator because the minimum scope is unclear.
  • Do not disable TLS verification for provider/SonarQube callbacks or API calls.
  • Do not paste PATs/client secrets/private keys into source, logs, screenshots, or tickets.
  • Do not delete a SonarQube project or change project key to repair provider binding.
  • Do not lower a Quality Gate because provider delivery failed.
  • Do not blanket retry the entire scanner/build when the failure is a provider-only 401/403.
  • Do not keep sandbox credentials after the lab “just in case.”

Knowledge check

Quality Gate is PASS and GitHub returns 403 when posting a check. Should the code be rescanned?

Why does revoking an exposed credential matter even after deleting it from YAML?

Azure decoration suddenly fails after the PAT’s expiry date. Which layer owns the first repair?

Why is an empty Bitbucket “OAuth consumer” menu not proof SonarQube no longer supports Bitbucket?

What evidence distinguishes provider failure from Compute Engine failure?

Next lesson

Produce the provider-integration checkpoint packet

Lesson 5 packages the four-provider design, real task/gate, simulated delivery, failure/repair, and cleanup evidence.

Official references and version notes

Version and compatibility note

Rechecked 2026-09-08. Mandatory examples target Community Build 26.9.0.129388 and SonarScanner CLI 8.1.0.6389; current commercial reference points are SonarQube Server 2026 Release 4.1 and 2026.1.5 LTA. Native feature/maintenance branch and pull/merge-request analysis plus provider decoration start in Developer Edition. GitHub integration uses a GitHub App with explicit repository permissions; GitLab global integration uses a dedicated Reporter-capable personal/group token with api scope; Azure DevOps uses a dedicated technical PAT and Azure DevOps Extension/service endpoint; Bitbucket Cloud is currently transitioning terminology/credentials, with API tokens replacing App passwords for import and current provider UI using OAuth Clients even where some Sonar documentation still says OAuth Consumer. Multiple configurations/instances and several monorepo/enterprise integration capabilities begin in Enterprise. Recheck provider UI, token deprecations, patch notes, callback/base URL requirements, and exact permissions before production rollout.

First-failure evidence. Preserve the original ceTaskId and its server-side result before retrying a branch/PR analysis; a later successful task must not erase the causal evidence from the failed run.

Keep the academy open

Support free, practical DevOps education.

Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.

Ethereum / ERC-20
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0Send only Ethereum/ERC-20 compatible assets to this address.