The last analysis has failed

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)?

SonarQube * Version 7.1 (build 11001)

  • what are you trying to achieve?

I want to initiate a scan of my source code from a Jenkins pipeline and have the results show up under that project/branch in sonarqube.

  • what have you tried so far to achieve this?

I am initiating a processing run from Jenkins by way of Maven. In one stage of my pipeline, I run the following maven command

mvn -Dsonar.branch.name=${scmVars.GIT_BRANCH} org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar

The scan submits and runs. A URL is returned to Jenkins in the log as

[INFO] ANALYSIS SUCCESSFUL, you can browse http://code-quality.my-devops.com/dashboard/index/com.company:api-xyz

When I click through to that link, I can see results for an old scan of the master branch, but not the branch name I used to submit the job. There is a red banner across the top saying The last analysis has failed.

There is another link of the form http://code-quality.my-devops.com/api/ce/task?id=VIIyT0jLAWWmnGLyGhcd which shows a JSON document like the following.

{
    "task": {
        "id": "VIIyT0jLAWWmnGLyGhcd",
        "type": "REPORT",
        "componentId": "AWNBs4Gefnkf2xGjvefC",
        "componentKey": "com.company:api-xyz",
        "componentName": "api-xyz",
        "componentQualifier": "TRK",
        "analysisId": "AWWmVIhpsjXSQABH-Bo0",
        "status": "SUCCESS",
        "submittedAt": "2018-09-04T20:44:40+0000",
        "submitterLogin": "jenkins",
        "startedAt": "2018-09-04T20:44:42+0000",
        "executedAt": "2018-09-04T20:44:42+0000",
        "executionTimeMs": 411,
        "logs": false,
        "hasScannerContext": true,
        "organization": "default-organization",
        "branch": "feature/jenkins",
        "branchType": "SHORT"
    }
}

The following screenshot shows that the jenkins jobs are submitted, but they never show up in the actual results or under the specified branch.

How can I get the results of the scan to show up under that project/branch in sonarqube?

Hi,

Thanks for the well-detailed report! :slight_smile:

It looks like a couple things are going on here. First, when you click the “you can browse” link, you end up on the main project branch. You should see a dropdown arrow next to “master” though. Click it to get a list of the project’s branches and PRs, and use that menu to navigate to the one of interest.

From your JSON document, it appears that analysis of the branch of interest is succeeeding

However, you do have a branch that is failing. To get to the underlying problem of that branch, click on the gear icon/dropdown on the right-hand side of that top/failed row. You’ll see an option labeled something like “Error logs” (I don’t have an example in front of me right now). Click it to see the error message.

HTH,
Ann

Hi Ann,

I have clicked through to the branch, which I see here: (can’t upload because I’m a new member)

When I get there, I don’t see any results. Everything on that branch looks empty.

Also, when I click on the Activity link, I can’t see the recent scan. Is that only for master? When I click to the branch, you can see that there isn’t an overview, activity, issues or anything else…

Here’s the last image I couldn’t upload

sonarqube-branches-2018-09-05_10-40-58

I also found the error you mentioned.

Error Details
Validation of project failed:
  o Date of analysis cannot be older than the date of the last known analysis on this project. Value: "2018-09-04T19:49:26+0000". Latest analysis: "2018-09-04T19:50:31+0000". It's only possible to rebuild the past in a chronological order.

Other than that, all the scans appear to succeed, but I can’t see the results of the scans anywhere?

1 Like

Hi,

You are actually seeing the results of your analyses; they’re telling you that no new issues were found in the branch, as compared with your target branch (this defaults to master). So your “We couldn’t find any results” message is actually a good thing. (We’ve updated this message in more recent versions to be more affirmatively positive, BTW).

The error message you’re getting in the failed background task indicates that you tried to use sonar.projectDate to back-date an analysis, but you can’t run retroactive analyses. That is, you can’t analyze for 1 Jan 2018, and then for 25 Dec 2017; you have to do them in order.

Ann

Thank you.

Can you help me understand how to view the Overview page. Does that ever represent scan results for branches? It sounds like the branch scan will only ever show a delta from the last scan of master, and in my case, there are no differences between master and my branch, which is why I don’t see anything. Is that right?

Is there some way to see an “Overview” of my branch, instead of a delta?

Hi,

What you’ve shown is a Short-lived branch (SLB). The assumption is that all that matters to you is analysis of what has changed since the branch was … branched off of the main branch.

In 7.1 all that’s really available in terms of analysis for SLBs is the new issues raised in the branch. Your branch doesn’t add any issues, so that’s why you see an empty result set.

It’s not clear to me what you’re after when you ask for ‘an “Overview” of my branch, instead of a delta’, but 7.4 will add coverage reporting (assuming you feed in a coverage report) and possibly duplications, depending on how far we get by the end of the month. You can check our progress on our dogfood server, next.sonarqube.com. Here’s a PR with coverage.

BTW, SLBs and PRs don’t show delta from the last scan of master, but from their branch points. 7.4 will include some improvements here too, so since this is a topic of interest for you, you probably want to upgrade quickly once it’s out.

Does this make sense? Does it answer your questions?

Ann

2 Likes

It’s getting more clear. By overview, I was thinking I could get something that looked like this screen

1 Like

That’s available for long-lived branches. The docs explain the differences between the two types.

Ann

2 Likes

A post was split to a new topic: Analysis date error while projects reloading