versions used (SonarQube - 9.4.0.54424)
Recently upgraded to Development version and tried to set up SonarQube as per documentation.
Using Github actions for CI
SonarQube set up was done as per the documentation:
https://docs.sonarqube.org/latest/analysis/github-integration/
error observed - “dev” branch has not been analyzed yet and you have multiple branches already. It looks like it is not your Main Branch, check your configuration.
Can anyone help me to fix this issue please.
Colin
(Colin)
June 2, 2022, 9:27am
2
Hey there.
How is your GitHub Actions YML file configured? Feel free to paste it here.
name: Sonar-Analysis
on:
pull_request:
branches:
- dev
types: [opened, edited, synchronize, reopened]
jobs:
build:
name: Sonar-Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.2.0
with:
# Disabling shallow clone is recommended for improving relevancy of sonarqube reporting
fetch-depth: 0
- name: Setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.x'
- name: Install dependencies
run: dotnet restore
- name: SonarQube Begin
run: |
dotnet tool install --global dotnet-sonarscanner
dotnet sonarscanner begin /k:"xxxxxxxxxxxxxxxxxxxx" /d:sonar.login=${{ secrets.SONAR_TOKEN }} /s:$GITHUB_WORKSPACE/SonarQube.Analysis.xml /d:sonar.verbose=true
- name: Build
run: dotnet build
# - name: Test with the dotnet CLI
# run: dotnet test --settings coverlet.runsettings --logger:trx
# env:
# ASPNETCORE_ENVIRONMENT: dev
- name: SonarQube end
run: dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
## Please advise if I have to make any changes.
Colin
(Colin)
June 2, 2022, 9:44am
4
So it looks like your conditions to run the job only include pull requests that target the dev
branch, not pushes to the dev
branch itself.
A better condition would be:
on:
push:
branches:
- dev
pull_request:
types: [opened, synchronize, reopened]
Thank you Colin, I am implementing the changes and will post in case if there is any error.
I have implemented the changes and it worked , just wanted to check with one warning thats displayed. could you please comment on the below warning message.
HI, could you please help me how to make sure that my sonar is updated to the latest date.
The date shows as June 6 however the PR shows the correct date, could you suggest if there is any setting that needs to be updated.