Interview Prep/Jenkins/Jenkinsfile syntax, Groovy & CPS errors

`java.lang.NoSuchMethodError: No such DSL method 'withSonarQubeEnv' found among steps [archive, bat, build, ...]`

BeginnerTroubleshootingJenkinsfile syntax, Groovy & CPS errors
Answer

Likely causes → The plugin providing the step (SonarQube Scanner) is not installed or failed to load, or the step name is misspelled.

Diagnose →

curl -s -u admin:$TOKEN "https://jenkins/pluginManager/api/json?depth=1&tree=plugins[shortName,active,enabled]" | jq '.plugins[] | select(.shortName=="sonar")'

Check Manage Jenkins > Plugins > Installed and startup logs for load failures.

Fix → Add sonar to plugins.txt, rebuild the image, redeploy. Fix spelling if it is a typo.

Prevent → Keep a smoke pipeline that calls every step your library relies on, run after each image change.

All Jenkins questions Roadmap: Jenkins

More on Jenkinsfile syntax, Groovy & CPS errors