The format of the analysis property sonar.token= is invalid

Dear Community:

Can you advise how to resolve the error message “The format of the analysis property sonar.token= is invalid

Below are the first 3 log entries when the Sonar Scanner starts:

SonarScanner for MSBuild 6.1
Using the .NET Core version of the Scanner for MSBuild
The format of the analysis property sonar.token= is invalid

Below is the template I use:

name: SonarCloud
on:
  push:
    branches:
      - main
  pull_request:
    types: [opened, synchronize, reopened]
jobs:
  build:
    name: Build and analyze
    runs-on: windows-latest
    steps:
      - name: Set up JDK 17
        uses: actions/setup-java@v3
        with:
          java-version: 17
          distribution: 'zulu' # Alternative distribution options are available.
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0  # Shallow clones should be disabled for a better relevancy of analysis
      - name: Cache SonarCloud packages
        uses: actions/cache@v3
        with:
          path: ~\sonar\cache
          key: ${{ runner.os }}-sonar
          restore-keys: ${{ runner.os }}-sonar
      - name: Cache SonarCloud scanner
        id: cache-sonar-scanner
        uses: actions/cache@v3
        with:
          path: .\.sonar\scanner
          key: ${{ runner.os }}-sonar-scanner
          restore-keys: ${{ runner.os }}-sonar-scanner
      - name: Install SonarCloud scanner
        if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
        shell: powershell
        run: |
          New-Item -Path .\.sonar\scanner -ItemType Directory
          dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
      - name: Build and analyze
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
        shell: powershell
        run: |
          .\.sonar\scanner\dotnet-sonarscanner begin /k:"cfcu-demo-feb-2024_privatecicd" /o:"cfcu-demo-feb-2024" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
          <insert_your_build_command>
          .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"

Hi,

I’ll be honest and say I’ve never seen this particular error before.

I’m wondering if this is a (non-)interpolation problem. Could you echo the token out to your log and make sure it prints what you expect it to?

 
Thx,
Ann

I have a SONAR_TOKEN as a secret in a calling workflow.
The called workflow try to read this as a secret without success.

This will not work

jobs:
  call-template:
    uses: myorg/myrepo/.github/workflows/mytemplate.yml@main

This works

jobs:
  call-template:
    uses: myorg/myrepo/.github/workflows/mytemplate.yml@main
    secrets: inherit
1 Like

Hi,

I’m glad you worked through this!

I’m going to route this thread to the Documentation team, but first, can you share what DevOps platform you’re using?

 
:smiley:
Ann

We are using GitHub Enterprise Cloud as our DevOps platform.

1 Like

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