Interview Prep/Jenkins/Integration failures: SonarQube, Nexus, Docker, Trivy, kubectl

`java.lang.IllegalStateException: Unable to get SonarQube task id and/or server name. Please use the 'withSonarQubeEnv' wrapper to run your analysis.`

IntermediateTroubleshootingIntegration failures: SonarQube, Nexus, Docker, Trivy, kubectl
Answer

Likely causes → waitForQualityGate called in a build where the analysis did not run inside withSonarQubeEnv, the analysis ran on another agent and report-task.txt is not found, or analysis failed earlier.

Diagnose → Confirm withSonarQubeEnv('sonarqube') wraps the scanner; look for .scannerwork/report-task.txt (or target/sonar/report-task.txt for Maven).

Fix → Wrap the scanner call with withSonarQubeEnv; run gate in the same build after analysis.

Prevent → Library step that does analysis and gate together.

All Jenkins questions Roadmap: Jenkins

More on Integration failures: SonarQube, Nexus, Docker, Trivy, kubectl