Files being excluded by scm ignore (despite no .gitignore file)

Must-share information (formatted with Markdown):

  • SonarQube 7.8.1, Jenkins 2.207, SonarScanner Plugin
  • I am trying to do static code analysis on a multi-module Java project. I have done this same setup on multiple other projects and not had an issue. However, this project will not show the source code within SonarQube.
  • In my Jenkinsfile I have configured the SonarQubeEnv correctly and am doing the following:
    mvn -B -U clean test install sonar:sonar deploy

The project shows up in SonarQube, but says there are no lines of code. I enabled debug by adding -X to the mvn goals and here is what I see in the logs:

[2020-01-08T19:13:09.460Z] [main] INFO org.sonarsource.scanner.maven.SonarQubeMojo - 19:13:09.457 Indexing files...
[2020-01-08T19:13:09.461Z] [main] INFO org.sonarsource.scanner.maven.SonarQubeMojo - 19:13:09.458 Project configuration:
[2020-01-08T19:13:09.492Z] [main] DEBUG org.sonarsource.scanner.maven.SonarQubeMojo - 19:13:09.489 readpipe [git, --version],/usr/bin
[2020-01-08T19:13:09.505Z] [main] DEBUG org.sonarsource.scanner.maven.SonarQubeMojo - 19:13:09.501 readpipe may return 'git version 2.11.0'
[2020-01-08T19:13:09.505Z] [main] DEBUG org.sonarsource.scanner.maven.SonarQubeMojo - 19:13:09.502 remaining output:
[2020-01-08T19:13:09.505Z] 
[2020-01-08T19:13:09.506Z] [main] DEBUG org.sonarsource.scanner.maven.SonarQubeMojo - 19:13:09.502 readpipe [git, config, --system, --edit],/usr/bin
[2020-01-08T19:13:09.510Z] [main] DEBUG org.sonarsource.scanner.maven.SonarQubeMojo - 19:13:09.507 readpipe may return '/etc/gitconfig'
[2020-01-08T19:13:09.511Z] [main] DEBUG org.sonarsource.scanner.maven.SonarQubeMojo - 19:13:09.507 remaining output:
[2020-01-08T19:13:09.511Z] 
[2020-01-08T19:13:09.623Z] [main] DEBUG org.sonarsource.scanner.maven.SonarQubeMojo - 19:13:09.619 241 non excluded files in this Git repository
[2020-01-08T19:13:09.628Z] [main] INFO org.sonarsource.scanner.maven.SonarQubeMojo - 19:13:09.624 Indexing files of module 'licensing-keygen'
[2020-01-08T19:13:09.629Z] [main] INFO org.sonarsource.scanner.maven.SonarQubeMojo - 19:13:09.625   Base dir: /var/jenkins/workspace/liquibasePro/DAT-3538/17/liquibase-pro/licensing/keygen
[2020-01-08T19:13:09.631Z] [main] DEBUG org.sonarsource.scanner.maven.SonarQubeMojo - 19:13:09.628   Source paths: pom.xml, src/main/java
[2020-01-08T19:13:09.632Z] [main] DEBUG org.sonarsource.scanner.maven.SonarQubeMojo - 19:13:09.629   Test paths: src/test/java
[2020-01-08T19:13:09.637Z] [main] DEBUG org.sonarsource.scanner.maven.SonarQubeMojo - 19:13:09.633 File '/var/jenkins/workspace/liquibasePro/DAT-3538/17/liquibase-pro/licensing/keygen/pom.xml' is excluded by the scm ignore settings.
[2020-01-08T19:13:09.645Z] [main] DEBUG org.sonarsource.scanner.maven.SonarQubeMojo - 19:13:09.641 File '/var/jenkins/workspace/liquibasePro/DAT-3538/17/liquibase-pro/licensing/keygen/src/main/java/liquibase/pro/license/keygen/DaticalLicenseManagementContext.java' is excluded by the scm ignore settings.
[2020-01-08T19:13:09.648Z] [main] DEBUG org.sonarsource.scanner.maven.SonarQubeMojo - 19:13:09.643 File '/var/jenkins/workspace/liquibasePro/DAT-3538/17/liquibase-pro/licensing/keygen/src/main/java/liquibase/pro/license/keygen/DaticalLicenseValidation.java' is excluded by the scm ignore settings.
[2020-01-08T19:13:09.649Z] [main] DEBUG org.sonarsource.scanner.maven.SonarQubeMojo - 19:13:09.645 File '/var/jenkins/workspace/liquibasePro/DAT-3538/17/liquibase-pro/licensing/keygen/src/main/java/liquibase/pro/license/keygen/LicensingSchema.java' is excluded by the scm ignore settings.

I have removed the .gitignore files completely just to make sure it wasn’t a bad pattern. Still the same result. There is no project-based exclusions or global exclusions as all of our other projects have worked fine by default. Where can I find what is causing these to be excluded?

Does it uses git submodules? IIRC submodules are ignored by the git plugin.

Try to run git ls-tree -r HEAD in your git repo and check if the mentioned files are listed.

@felipebz thank you. Yes, when I run that command I do see the mentioned files listed. Note that we do use profiles in our pom because the base of our code is open-source, but then we have an offering with additional functionality that is a paid offering. If i remove the profiles the static code analysis works fine, but I have to have the profiles in our poms. How can I workaround this?

Thanks!

Hi Jake,
The scanner will only non-excluded files in the git repository.
What exactly do the pom profiles do? What could be the link with git?