Pull request analysis was successful, but branch analysis always showed background task failed

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    Sonarqube: Enterprise edition 9.7.1
    database: postgresql 14.2 in docker

  • what are you trying to achieve
    build a jenkins job,analyze a bitbucket branch successful.

  • what have you tried so far to achieve this
    Create a new sonarqube project with build-in profile, branch analysis points to the newly created project, but also shows that the background task failed.

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

background_jenkins.log (24.5 KB)

Hi,

We worked on something very similar to this in 9.8:

SONAR-17597 NullPointerException when CE loads SCM changesets from DB

Can you upgrade and try again?

 
Ann

YES,we upgrade to enterprise edition 9.8 and then background task failed again.

Hi,

Thanks for trying. I’m going to flag this for team attention.

 
Ann

Hi Ann ,

  Is there any progress on this issue ?

Honghua

Hi @honghua ,

I see the following exception in your logs:

Caused by: java.lang.IllegalStateException: Fail to process issues of component 'IData_performance_center:pom.xml'
	at org.sonar.ce.task.projectanalysis.issue.IntegrateIssuesVisitor.visitAny(IntegrateIssuesVisitor.java:106)
	at org.sonar.ce.task.projectanalysis.component.TypeAwareVisitorWrapper.visitAny(TypeAwareVisitorWrapper.java:77)
	...
Caused by: java.lang.IllegalStateException: Changeset on line 1 must have a date
	at com.google.common.base.Preconditions.checkState(Preconditions.java:562)
	at org.sonar.ce.task.projectanalysis.scm.ReportScmInfo$LineIndexToChangeset.convert(ReportScmInfo.java:72)
	...

Is there anything special about this IData_performance_center module? Or its pom.xml?

Hi Wouter ,

 Thanks for your reply !
  IData_performance_center is the project name in sonarqube ,and attached is the project's pom.xml.

pom.zip (1.6 KB)

Hi @honghua ,

Looking at those logs again, I see you have 2 errors on these pom.xml files:

  • IData_performance_center:commons-dynamic-datasource/pom.xml
  • IData_performance_center:pom.xml

Both times, the error is that the report uploaded to the SonarQube server doesn’t contain any SCM information for those files (at least, not for the first line). Hence these error messages for both files:

Caused by: java.lang.IllegalStateException: Changeset on line 1 must have a date

Are you using an SCM (e.g., Git, SVN, Mercurial, …) for your project? If yes, and you’re not using SVN or Git (which SonarQube supports out of the box), have you installed a plugin that provides this support? For example, the CVS plugin, Mercurial plugin, or TFVC plugin?

Hi Wouter ,

Thanks for your reply!
We don’t use those plugins and I configure scm as git ,but it does’t work.

Can you elaborate a bit? What doesn’t work, exactly?

Under project General Settings ,tab to SCM ,set ‘key of the SCM provider for this project’ attribute value as ‘git’.But after sonar-scanner analysis , background task show failed .

Even after deleting the project and rebuilding a new one with the same name and projectkey,sonar scans it and still reports background task failed

That setting shouldn’t be necessary. If you need to use it, it implies you’re in a special case where you use multiple SCMs, and you need to tell the scanner which one to use. If you’re only using git, you can (and should) leave that empty. But, are you actually checking out a git repo on Jenkins? Just telling SonarQube to use git doesn’t mean it works.

The error you have is that the Scanner cannot determine any git blame info for these 2 pom.xml files. Why is that? Are these files part of your git repository? Is the checkout working correctly? Can you analyze the project locally? You can find instructions on how to analyze your project by going to SonarQube, navigate to your project, and then, either:

  • If your project has never been analyzed before, pick the “local” tutorial and follow the steps.
  • If your project was analyzed before, but only has a single branch, hover over the little “+” icon and select “Show me how to set up my CI”, pick the “local” tutorial and follow the steps.
    menu
  • Else, replace the /dashboard part of your URL with /tutorials (keep the ?id=... parameter as-is), pick the “local” tutorial and follow the steps.

If you can analyze your project locally, it could mean something is wrong with how you set up your project on Jenkins. I suspect something is wrong with how the code is checked out from git, and/or that some of these files (like the pom.xml files) are not actually part of your git repository, but that they are copied from somewhere, or generated on the fly. If this is the case, you should change your project parameters to exclude those files/folders from the analysis (see documentation here).