Skip to content

Commit

Permalink
sonarqube changes
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Jul 21, 2023
1 parent 9b3ba10 commit 1c223a3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion documentation/docs/developer-guide/azure-devops/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ So **no** desktop application is build. This is referenced by: `pipelines/azure/
The following variables are used:

- `$(STARSKY_SONAR_KEY)` - project key for sonarcloud
- `$(STARSKY_SONAR_LOGIN)` - login key for sonarcloud
- `$(STARSKY_SONAR_TOKEN)` - login key for sonarcloud
- `$(STARSKY_SONAR_ORGANISATION)` - organisation in sonarcloud

### azure-pipelines-starsky-shared-web-only
Expand Down
16 changes: 8 additions & 8 deletions starsky/build/helpers/SonarQube.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,16 @@ private static void IsJavaInstalled()
public static bool SonarBegin(bool noUnitTest, bool noSonar, string branchName, string clientAppProject, string coverageFile)
{
var key = EnvironmentVariable("STARSKY_SONAR_KEY");
var login = EnvironmentVariable("STARSKY_SONAR_LOGIN");
var sonarToken = EnvironmentVariable("STARSKY_SONAR_TOKEN");
var organisation = EnvironmentVariable("STARSKY_SONAR_ORGANISATION");

var url = EnvironmentVariable("STARSKY_SONAR_URL");
if(string.IsNullOrEmpty(url)) {
url = "https://sonarcloud.io";
}

if( string.IsNullOrEmpty(key) || string.IsNullOrEmpty(login) || string.IsNullOrEmpty(organisation) ) {
Information($">> SonarQube is disabled $ key={key}|login={login}|organisation={organisation}");
if( string.IsNullOrEmpty(key) || string.IsNullOrEmpty(sonarToken) || string.IsNullOrEmpty(organisation) ) {
Information($">> SonarQube is disabled $ key={key}|login={sonarToken}|organisation={organisation}");
return false;
}

Expand Down Expand Up @@ -152,7 +152,7 @@ public static bool SonarBegin(bool noUnitTest, bool noSonar, string branchName,
.Append($"/d:sonar.host.url=\"{url}\" ")
.Append($"/k:\"{key}\" ")
.Append($"/n:\"Starsky\" ")
.Append($"/d:sonar.login=\"{login}\" ")
.Append($"/d:sonar.token=\"{sonarToken}\" ")
.Append($"/o:" + organisation +" ")
.Append($"/d:sonar.typescript.tsconfigPath={tsconfig} ")
.Append($"/d:sonar.coverageReportPaths={sonarQubeCoverageFile} ")
Expand Down Expand Up @@ -200,9 +200,9 @@ public static bool SonarBegin(bool noUnitTest, bool noSonar, string branchName,

public static void SonarEnd(bool noUnitTest, bool noSonar)
{
var login = EnvironmentVariable("STARSKY_SONAR_LOGIN");
if( string.IsNullOrEmpty(login) ) {
Information($">> SonarQube is disabled $ login={login}");
var sonarToken = EnvironmentVariable("STARSKY_SONAR_TOKEN");
if( string.IsNullOrEmpty(sonarToken) ) {
Information($">> SonarQube is disabled $ login={sonarToken}");
return;
}

Expand All @@ -219,7 +219,7 @@ public static void SonarEnd(bool noUnitTest, bool noSonar)
var sonarArguments = new StringBuilder()
.Append($"sonarscanner ")
.Append($"end ")
.Append($"/d:sonar.login=\"{login}\" ");
.Append($"/d:sonar.token=\"{sonarToken}\" ");

DotNet(sonarArguments.ToString());

Expand Down
2 changes: 1 addition & 1 deletion starsky/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ For SonarScanner you need to additionally install:
To enable SonarScanner you need to set the following environment variables:

- `STARSKY_SONAR_KEY` - the public name of the project
- `STARSKY_SONAR_LOGIN` - the token to login
- `STARSKY_SONAR_TOKEN` - the token to login
- `STARSKY_SONAR_ORGANISATION` - the name of the organisation
- `STARSKY_SONAR_URL` - defaults to sonarcloud.io

Expand Down

0 comments on commit 1c223a3

Please sign in to comment.