definitions:
  steps:
    - step: &build-step
        name: SonarQube analysis
        image: maven:3.8.3-jdk-11
        size: 8x
        script:
          - pipe: sonarsource/sonarqube-scan:3.0.2
            variables:
              SONAR_HOST_URL: ${SONAR_HOST_URL}
              SONAR_TOKEN: ${SONAR_TOKEN}
              EXTRA_ARGS: >
                -Dsonar.scanner.forceEmbeddedJava=true
                -Dsonar.scanner.jvmOpts=-Xmx4g
                -Dsonar.exclusions=**/*.test.js,**/node_modules/**,**/vendor/**
                -Dsonar.projectKey=my-project
                -Dsonar.sources=.
        caches:
          - sonar

  caches:
    sonar: ~/.sonar

clone:
  depth: 50

pipelines:
  branches:
    '{main,develop}':
      - step: *build-step
  pull-requests:
    '**':
      - step: *build-step