0

I am trying to integrate sonarcloud with Bitbucket pipeline. I have a simple test project with single file named index.php consisting few lines.

I am exactly not sure what method should I follow.

I have created sonar-project.properties files that consists following lines.

sonar.sourceEncoding=UTF-8
sonar.host.url=https://sonarcloud.io/dashboard?id=first_ftp
sonar.projectKey=first_ftp

Here is my yml file

image: aariacarterweir/lamp-gitftp:latest

clone:
  depth: full # SonarCloud scanner needs the full history to assign issues properly

definitions:
  caches:
    sonar: ~/.sonar/cache  # Caching SonarCloud artifacts will speed up your build
  steps:
    - step: &build-test-sonarcloud
        name: Build, test and analyze on SonarCloud
        caches:
          - node
          - sonar
        script:
          - npm install --quiet
          - npm run test -- --code-coverage --no-watch --no-progress --browsers=ChromeHeadlessNoSandbox  
          - pipe: sonarsource/sonarcloud-scan:0.1.5
            variables:
              SONAR_TOKEN: ${SONAR_TOKEN}
              EXTRA_ARGS: '-Dsonar.sources=src -Dsonar.tests=src -Dsonar.test.inclusions="**/testing/**,**/*.spec.ts" -Dsonar.typescript.lcov.reportPaths=coverage/lcov.info'

When I check into sonarcloud website, It tells

The main branch has no lines of code

Can anybody help me how to configure properly sonarcloud with bitbucket for php project.

nas
  • 2,289
  • 5
  • 32
  • 67
  • Are you sure there is code under `src`? Please include the output of the scanner run (the pipe). – janos Oct 05 '19 at 20:15

2 Answers2

1

I've had the same issue - in my case it was because of the name of the project - it was called ---------Test, and apparently, by default, Sonar will treat that as a test assembly and will exclude it from analysis.

Marius Bughiu
  • 997
  • 14
  • 32
0

Before running code analysis in bitbucket pipelines, you would have to first manually run analysis(only once). By following below steps. enter image description here

Nayan shah
  • 543
  • 3
  • 8
  • Yes I have done this. But I get nothing. My project consists of only index.php at this moment with some lines of code with missing ; and }. But I am not getting any error in sonarcloud – nas Jul 17 '19 at 16:41