0

I am very new to sonarcloud. I am trying to implement sonarcloud into the bitbucket pipeline.

I follow the tutorial for sonarcloud to analyze the new project then I get following code to run.

sonar-scanner.bat -D"sonar.projectKey=mywebsite" -D"sonar.organization=xxxxxxxx-bitbucket" -D"sonar.sources=." -D"sonar.host.url=https://sonarcloud.io" -D"sonar.login=xxxxxxxxxxxxxxxxx"

When I run this, it shows me error in my code and with some message at the end.

INFO: ANALYSIS SUCCESSFUL, you can browse https://sonarcloud.io/dashboard?id=mywebsite
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at https://sonarcloud.io/api/ce/task?id=XXXXXXXXXXXXXXXXX

But when I check into the given link it shows empty.

I have following lines in my bitbucket-pipeline.yml file

image: atlassian/default-image:2

definitions:
  caches:
    sonar: ~/.sonar/cache

  steps:
    - step: &sonarcloud
        name: Analyze on SonarCloud
        caches:
          - sonar
          - composer
        script:
          - apt-get update
          - composer update --no-interaction --no-suggest --no-progress
          - vendor/bin/phpunit --coverage-clover=coverage-report.clover --log-junit=test-report.xml
          - sonar-scanner
          - pipe: sonarsource/sonarcloud-scan:0.1.5
            variables:
              SONAR_TOKEN: ${SONAR_TOKEN}
pipelines:

Can any body please help me how can I integrate this sonar to bitbucket?

Thank You.

user1687891
  • 794
  • 2
  • 14
  • 30
  • What do you mean "it shows empty" ? On SonarCloud page of your project, what do you see in the **Code** tab? Also, please include the output of the sonarcloud-scan pipe, and if your repository has a file named `sonar-project.properties`, then please share its content. – janos Oct 05 '19 at 19:47

1 Answers1

2

Try this step script:

  services:
    docker:
      memory: 2560

  steps:
    - step: &sonarcloud
        name: Analyze on SonarCloud
        caches:
          - docker
        script:
          - pipe: sonarsource/sonarcloud-scan:1.0.1
            variables:
              SONAR_TOKEN: ${SONAR_TOKEN}
        services:
          - docker

More info: https://gist.github.com/GetoXs/e2b323b048aad88c12a10aceba3cc6cd

GetoX
  • 4,225
  • 2
  • 33
  • 30