Configuration error for bitbucket pipeline

Hi I am new to Sonarcloud and I am trying to setup bitbucket pipeline (bitbucket cloud) I have followed all the steps in the pipeline but there is a configuration error for a python project to be imported I have attached the pipeline code for the same I am unable to understand why its giving the error

image: python:3.8 # Choose an image matching your project needs

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:
        - pip           # See https://confluence.atlassian.com/bitbucket/caching-dependencies-895552876.html
        - sonar
      script:
        - pipe: sonarsource/sonarcloud-scan:1.2.0
          variables:
            SONAR_TOKEN: ${SONAR_TOKEN}
        
    - step: &check-quality-gate-sonarcloud
      name: Check the Quality Gate on SonarCloud
      script:
        - pipe: sonarsource/sonarcloud-quality-gate:0.1.4
          variables:
            SONAR_TOKEN: ${SONAR_TOKEN}


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

sonarcloud_error

Please help me understand why my build is failing

Welcome to the community!

This is really a configuration issue using Bitbucket Cloud, and not specific to SonarCloud. There is a syntax error in the yaml, you need to use a bit deeper indent in the step definitions, like this:

image: python:3.8 # Choose an image matching your project needs

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:
          - pip           # See https://confluence.atlassian.com/bitbucket/caching-dependencies-895552876.html
          - sonar
        script:
          - pipe: sonarsource/sonarcloud-scan:1.2.0
            variables:
              SONAR_TOKEN: ${SONAR_TOKEN}

    - step: &check-quality-gate-sonarcloud
        name: Check the Quality Gate on SonarCloud
        script:
          - pipe: sonarsource/sonarcloud-quality-gate:0.1.4
            variables:
              SONAR_TOKEN: ${SONAR_TOKEN}


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

Btw, with recent versions of the SonarCloud pipes (yours is recent enough), you don’t need to explicitly specify the SONAR_TOKEN variable anymore, it will be picked up automatically.

thankyou so much ! Really appreciate this

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.