Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dylan-smith/sonarqube-buildbreaker
https://github.com/dylan-smith/sonarqube-buildbreaker
Last synced: 22 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/dylan-smith/sonarqube-buildbreaker
- Owner: dylan-smith
- License: mit
- Created: 2020-11-03T23:27:46.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-01-16T23:08:19.000Z (almost 2 years ago)
- Last Synced: 2024-10-31T10:44:24.095Z (about 2 months ago)
- Language: TypeScript
- Size: 1000 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Introduction
This GitHub Action is based on a popular Azure DevOps task: https://marketplace.visualstudio.com/items?itemName=SimondeLang.sonarqube-buildbreakerIt will connect to SonarQube, wait for your analysis job to complete, then either pass or fail your GitHub build based on the status of the SonarQube Quality Gate.
NOTE: If you are using SonarCloud use this action instead: https://github.com/dylan-smith/sonarcloud-buildbreaker
# Getting Started
You need to pass this task your SonarQube URL (e.g. http://sonarqube.contoso.com:9000), and SonarQube token. See instructions here for getting your SonarQube token: https://docs.sonarqube.org/latest/user-guide/user-token/```yaml
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.301
- name: Setup Java 11
uses: actions/setup-java@v1
with:
java-version: '11' # The JDK version to make available on the path.
java-package: jre # (jre, jdk, or jdk+fx) - defaults to jdk
- name: Install Sonar scanner
shell: pwsh
run: |
New-Item -Path ./.sonar/scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner --version 4.10.0
- name: Prepare Sonar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: pwsh
run: ./.sonar/scanner/dotnet-sonarscanner begin /k:"my-sonar-project" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="http://sonarqube.contoso.com:9000"
- name: Install dependencies
run: dotnet restore src/AdventOfCode.sln
- name: Build
run: dotnet build src/AdventOfCode.sln --configuration Release --no-restore
- name: SonarQube Analysis
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: pwsh
run: ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
- name: Break Build on SonarQube Quality Gate
uses: dylan-smith/sonarqube-buildbreaker@main
with:
sonarUrl: "http://sonarqube.contoso.com:9000"
sonarToken: ${{ secrets.SONAR_TOKEN }}
```