image: mcr.microsoft.com/dotnet/sdk:7.0

definitions:
  steps:
    - step: &build-step
        name: SonarQube analysis
        caches:
          - dotnetcore
          - sonar
        script:
          - apt-get update
          - apt-get install --yes --no-install-recommends openjdk-17-jre
          - dotnet tool install --global dotnet-sonarscanner
          - export PATH="$PATH:/root/.dotnet/tools"
          - dotnet sonarscanner begin /k:"overdrive_shipment_document_system_dccdf710-08f7-47e7-bc1c-d390c06b0c7f" /d:"sonar.token=${SONAR_TOKEN}"  /d:"sonar.host.url=${SONAR_HOST_URL}"
          - dotnet build **/rgbc_sds.sln
          - dotnet sonarscanner end /d:"sonar.token=${SONAR_TOKEN}"
  caches:
    sonar: ~/.sonar

pipelines:
  branches:
    '{main}':
      - step: *build-step
