When I make a commit on a branch with an open PR, two builds will be kicked off. One branch build and one PR build.
Since moving to 8.3, Sonar is now detecting the PR build and doing PR analysis. The problem is that when the analysis completes and the webhook is sent it is not detected by the plugin so the PR build just hangs around waiting.
The branch build on the other hand receives the webhook as expected and proceeds on to the next stage.
I have confirmed that both webhooks are sent and received by checking /admin/webhooks -> Recent Deliveries. I see a 200 OK status for both webhooks.
The SonarQube jenkins plugin version is 2.11.
To reproduce create a Jenkins job that builds both branches and PRs with a waitForQualityGate() stage. Make a commit to kick off both builds.
Expected behaviour:
Branch based sonar analysis completes
Branch based webhook is sent
Branch based build continues or fails depending on webhook response
PR based sonar analysis completes
PR based webhook is sent
PR based build continues or fails depending on webhook response
Actual behaviour:
Branch based sonar analysis completes
Branch based webhook is sent
Branch based build continues or fails depending on webhook response
PR based sonar analysis completes
PR based webhook is sent 6. PR based build does not process the webhook and continues to wait
I have two jobs running (one branch based and one PR based). Two webhooks are sent and the branch one is always processed successfully. The PR one is always missed.
This seems to match oddities that I have seen. We build in Jenkins using a GitHub “discover branches” behaviour configured for “Exclude branches that are also filed as PRs”. Occasionally, the PR pipeline will get stuck during quality gate, exactly as described in SONARJNKNS-320.
Once the PR build has failed in this way it then always fails for the same reason.
The solution for us is always the same and always works…
Change the job configuration so that discover branches = all branches.
Build the branch that was the basis for the PR. The QG passes.
Build the PR again. The QG passes. Nothing gets stuck.
PR can now be merged.
Changed pipeline configuration back to “Exclude branches that are also filed as PRs” (the bug strikes randomly and maybe 98% of our PRs have no QG issue).