Mid DevOps

Example scenario: When you push new code, SonarQube runs static analysis and flags issues like “missing null checks” or “unused variables” before the code gets merged. 4⃣ How do you ensure quality gates before deployment? Follow:

Quality gates are automated checks that your code must pass before it can be deployed.

Typical gates:

  • Code must pass all tests.
  • Code coverage ≥ 80%.
  • No critical SonarQube issues.
  • Build must succeed.

Ways to enforce them:

  • Branch policies: Block PRs until build and tests pass.
  • SonarQube gate: Fail the pipeline if quality gate fails.
  • Pipeline conditions: Only deploy if all checks succeed.

Example (YAML):

  • task: SonarQubePublish@5

inputs:

pollingTimeoutSec: '300'

condition: succeeded()

Example scenario:

If SonarQube reports a “Failed Quality Gate” due to high code duplication, the deployment

to QA is blocked until issues are fixed.

5⃣ How do you perform automated smoke testing after deployment?

Smoke tests verify that your deployed app is running and key endpoints work — without

doing deep functional testing.

You can run these as post-deployment steps in your release pipeline.

Follow:

Example (PowerShell):

  • task: PowerShell@2

inputs:

targetType: 'inline'

script: |

$response = Invoke-WebRequest

if ($response.StatusCode -ne 200) {

throw "Smoke test failed!"

Example scenario:

After deploying your API to QA, the pipeline runs a smoke test that checks:

  • /health endpoint returns 200
  • Database connection works

If it fails, the pipeline stops and alerts the team.

✅ Pro Tip:

Combine all testing and quality practices like this:

More from Microsoft Azure Tutorial

All questions for this course