Hi, we configured many of our sonarqube projects to have “dev” as the default branch, everything worked fine until about 3 weeks ago, when suddenly, without any changes in the sonarqube or jenkins configurations, we started seeing dozens of Jenkins jobs fail with error:
java.lang.IllegalStateException: Reference branch set with ‘sonar.newCode.referenceBranch’ points to the current branch ‘dev’
we was trying to deploy&analyze the dev branch.
These are the sonar properties in the example jenkins project:
sonar.projectKey=$JOB_BASE_NAME <- dev
sonar.projectName=$JOB_NAME
sonar.branch.name=$WASTE_BRANCH <- dev
sonar.sources=.
sonar.token=$sonar_token
How can we fix this error?
SQ v10.3.0 deployed by docker image 10.3.0-developer
Is it possible that sonar.newCode.referenceBranch got set by somebody in your global SonarQube server configuration on Jenkins (where you specify the SonarQube URL)?
Hi Colin,
unfortunately this is not the case, I checked and there are no custom parameters in the configuration.
Can I check something else?
Thanks a lot for the help.
Can you give us which version of the SonarQube Jenkins extension you’re using?
Also, could you, please, send me the full logs of a failing analysis? Ideally, and if you can do it, could you add a -X parameter to the build, so we can have full debug logs? The screenshot below shows where you can add this parameter.
What do you get if you query the API GET api/new_code_periods/list?project=<project-key>? Can you see something about the branch dev in there? Feel free to send the result here.
Have you tried analysing a different branch than dev? Does it work?
I was able to run a build without any errors, building from a different branch than dev; unfortunately when building dev the error continues to exist, as you can see in the attached file.