BitBucket pipe + Sonar Cloud + Node js

Hi ,

can i get the sample code for BitBucket pipe + Sonar Cloud + Node js (bitbucket-pipelines.yml) .

I used the following command but not working fine. Unable search the right forum.

  • step: &SonarCloud
    name: SonarCloud SCA
    image: node:14-alpine
    caches:
    - node
    - sonar
    script:
    - pipe: sonarsource/sonarcloud-scan:1.2.1
    variables:
    SONAR_TOKEN: ${SONAR_TOKEN}
    EXTRA_ARGS: ‘-Dsonar.sources=src -Dsonar.tests=src’

Thanks ,
Vengadeshan M

BitBucket pipe + Sonar Cloud + Node js

  1. Sonar cloud scan for nodejs application from BitBucket
  2. Sonar cloud quality gate check for nodejs application from BitBucket

Hey there.

Firstly, there’s a tutorial right in the UI when you create a project.

Secondly…

What about it isn’t working fine? Do you get an error? Unxpected results? There’s not much to go off of here.

Hi,
I referred the tutorial in the above mentioned image. But still getting error.

Please find the below my project structure and pipeline.yml code. Please let me know whether project folder structure issue or the yml file issue and what i have to change.?

image: node:14

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-script build
          - pipe: sonarsource/sonarcloud-scan:1.4.0
    - step: &check-quality-gate-sonarcloud
        name: Check the Quality Gate on SonarCloud
        script:
          - pipe: sonarsource/sonarcloud-quality-gate:0.1.6

pipelines:                 # More info here: https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html
  branches:
    master:
      - step: *build-test-sonarcloud
      - step: *check-quality-gate-sonarcloud
  pull-requests:
    '**':
      - step: *build-test-sonarcloud
      - step: *check-quality-gate-sonarcloud


d

Hi - Can you please help on my issue.

Hey there/

I’ll ask for a second time – what is the error that you receive?

The failure appears to be unrelated to SonarCloud and something that you added yourself. You will either need to troubleshoot running npm run-script build, or try removing it from your pipeline.