I am using the latest sonarqube community edition.
I have set up github actions as below.
jobs:
sonarqube-checks:
name: sonarqube-checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache SonarQube packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build and analyze
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: |
./gradlew build sonarqube --info
Have set up build.gradle like this.
plugins {
id "org.sonarqube" version "3.4.0.2513"
}
sonarqube {
properties {
property "sonar.projectKey", "<project-key>"
}
}
When the pipeline runs, it fails with this error
What went wrong:
Execution failed for task ':sonarqube'.
Youre not authorized to run analysis. Please contact the project administrator.
When I run it locally using the same token, analysis succeeds.
./gradlew sonarqube -D “sonar.projectKey=myProjectKey” -D “sonar.host.url=host” -D “sonar.login=myToken>”