We dont want to merge pull requests with a failed quality gate on TFS

We are using SonarQube and the dotnet-sonarscanner from nuget which works great.
Unfortunately, we are not able to get the information about the sonarqube scan and quality gates back to TFS.

We want to prevent PullRequests from being merged if the quality gate is not passed. I understood that you dont want to break the build anymore if the quality gate is broken.

I found something on the documentation (https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Extension+for+VSTS-TFS) but I am not finding the mentioned settings like “Administration -> General Settings -> Pull Requests”

Hi @aumanjoa,

May I ask if there is any reason why you are using the dotnet-sonarscanner global tool and not the SonarQube TFS extension?

If you install it you should be able to find the menu you are looking for.

Cheers,
Amaury

hi @Ammo

Many thanks for your replay.

We are using the dotnet-sonarscanner from nuget because we run all our builds within docker where we dont have any possibilty to use the SonarQube TFS Extension.

But is the part which does the magic with the integreation shareable and can be used from us as well?

dotnet tool install --global dotnet-sonarscanner --version 4.4.2
apt-get -yqq update && apt-get -yqq install openjdk-8-jre-headless > /dev/null


dotnet-sonarscanner begin /k:$BUILD_NAME /d:sonar.host.url="$SONAR_HOST" /d:sonar.login="$SONAR_LOGIN" /d:sonar.exclusions="**/bin/**/*,**/obj/**/*" /d:sonar.cs.opencover.reportsPaths=/src/opencover.xml /v:$BUILD_ID


dotnet build $UNITTEST_PROJECT
coverlet $UNITTEST_ASSEMBLY --target "dotnet" --targetargs "test $UNITTEST_PROJECT --no-build" --output /src/opencover.xml --format opencover
dotnet publish $PROJECT -c Release -o /app


dotnet-sonarscanner end /d:sonar.login="$SONAR_LOGIN"