Juan Pablo
Juan Pablo

Reputation: 653

Bitbucket Pipeline fails saying that step is empty, null or missing

I'm trying to configure a Bitbucket pipeline to execute the SonarQube pipe, but Bitbucket complains that the pipeline step is empty, null or missing.

I've got SONAR_TOKEN defined as a project variable with the correct token.

Here's my current bitbucket-pipeline.yml file:

image: atlassian/default-image:2

clone:
  depth: full

definitions:
  caches:
    sonar: ~/.sonar/cache
  steps:
    - step: &sonarcloud
      name: Analyze on SonarCloud
      caches:
        - sonar
      script:
        - pipe: sonarsource/sonarcloud-scan:0.1.5
          variables:
            SONAR_TOKEN: ${SONAR_TOKEN}

pipelines:
  branches:
    '*':
      - step: *sonarcloud

Any ideas?

Upvotes: 15

Views: 8185

Answers (1)

Juan Pablo
Juan Pablo

Reputation: 653

Found the issue.

The problem is that the step details in the definition area is incorrectly indented and is missing one extra indentation level.

Instead of:

...
- steps: &sonarcloud
  name: ...
  ...

It's

...
- steps: &sonarcloud
    name: ... // Notice the extra level of indentation
    ...

The correct YAML is:

image: atlassian/default-image:2

clone:
  depth: full

definitions:
  caches:
    sonar: ~/.sonar/cache
  steps:
    - step: &sonarcloud
        name: Analyze on SonarCloud
        caches:
          - sonar
        script:
          - pipe: sonarsource/sonarcloud-scan:0.1.5
            variables:
              SONAR_TOKEN: ${SONAR_TOKEN}

pipelines:
  branches:
    '*':
      - step: *sonarcloud

Upvotes: 31

Related Questions