("sonar_token", null);
+
+ if (string.IsNullOrWhiteSpace(sonarToken))
+ {
+ // Ensure the Sonar token is provided before proceeding
+ Error("Sonar token is required.");
+ Environment.Exit(255);
+ }
+
+ // Log the processing of the specific Keycloak version
+ Information($"Processing Keycloak Version: {kcMajorVersion.Value}");
+
+ // Set environment variables for Keycloak and SonarQube
+ Environment.SetEnvironmentVariable("KC_TEST_VERSION", $"prepare_keycloak_{kcMajorVersion.Value}_environment");
+ Environment.SetEnvironmentVariable("KC_SONAR_TOKEN", sonarToken);
+
+ // Execute the required setup, testing, and analysis tasks
+ RunTarget("Setup-Testing-Environment");
+ RunTarget("SonarBegin");
+ RunTarget("Test");
+ RunTarget("SonarEnd");
+ });
+
+// Execute the BuildTestAnalyse task
+RunTarget("BuildTestAnalyse");
diff --git a/NETCore.Keycloak.Client.Tests/cakeScripts/sonar_analysis.cake b/NETCore.Keycloak.Client.Tests/cakeScripts/sonar_analysis.cake
new file mode 100644
index 0000000..c550719
--- /dev/null
+++ b/NETCore.Keycloak.Client.Tests/cakeScripts/sonar_analysis.cake
@@ -0,0 +1,85 @@
+///
+/// Initiates SonarCloud analysis by executing the `dotnet sonarscanner begin` command.
+/// This task resolves the `dotnet` executable, ensures the required Sonar token is provided,
+/// and configures the necessary SonarCloud parameters for project analysis.
+///
+Task("SonarBegin")
+ .Does(() =>
+ {
+ // Retrieve the Sonar token from the environment variable
+ var sonarToken = Environment.GetEnvironmentVariable("KC_SONAR_TOKEN") ?? "";
+
+ if (string.IsNullOrWhiteSpace(sonarToken))
+ {
+ // Ensure the token is provided before proceeding
+ Error("Sonar token is required.");
+ Environment.Exit(255);
+ }
+
+ // Resolve the path to the `dotnet` executable
+ FilePath dotnetPath = Context.Tools.Resolve("dotnet");
+
+ // Configure process settings for executing the SonarScanner command
+ var processSettings = new ProcessSettings
+ {
+ Arguments = new ProcessArgumentBuilder()
+ .Append("sonarscanner begin")
+ .Append($"/d:sonar.token={sonarToken}")
+ .Append("/k:Black-Cockpit_NETCore.Keycloak")
+ .Append("/o:black-cockpit")
+ .Append("/d:sonar.host.url=\"https://sonarcloud.io\"")
+ .Append("/d:sonar.coverage.exclusions=\"**/NETCore.Keycloak.Client.Tests/**/*.*\"")
+ .Append("/d:sonar.test.exclusions=\"**/NETCore.Keycloak.Client.Tests/**/*.*\"")
+ .Append("/d:sonar.exclusions=\"**/NETCore.Keycloak.Client.Tests/**/*.*\"")
+ .Append("/d:sonar.cs.dotcover.reportsPaths=dotCover.Output.html"),
+ RedirectStandardOutput = true,
+ RedirectStandardError = true
+ };
+
+ // Execute the SonarScanner command
+ StartProcess(dotnetPath, processSettings);
+ });
+
+///
+/// Finalizes the SonarCloud analysis by executing the `dotnet sonarscanner end` command.
+/// This task ensures the required Sonar token is provided, resolves the `dotnet` executable,
+/// and captures the process output and error streams for evaluation.
+///
+Task("SonarEnd")
+ .IsDependentOn("Build")
+ .Does(() =>
+ {
+ // Retrieve the Sonar token from the environment variable
+ var sonarToken = Environment.GetEnvironmentVariable("KC_SONAR_TOKEN") ?? "";
+
+ if (string.IsNullOrWhiteSpace(sonarToken))
+ {
+ // Ensure the token is provided before proceeding
+ Error("Sonar token is required.");
+ Environment.Exit(255);
+ }
+
+ // Resolve the path to the `dotnet` executable
+ FilePath dotnetPath = Context.Tools.Resolve("dotnet");
+
+ // Configure process settings for executing the SonarScanner command
+ var processSettings = new ProcessSettings
+ {
+ Arguments = new ProcessArgumentBuilder()
+ .Append("sonarscanner end")
+ .Append($"/d:sonar.token={sonarToken}"),
+ RedirectStandardOutput = true,
+ RedirectStandardError = true
+ };
+
+ // Execute the SonarScanner command and capture output/error streams
+ var result = StartProcess(dotnetPath, processSettings, out var output, out var error);
+
+ // Evaluate the result of the process execution
+ if (result != 0)
+ {
+ // Log the error message and exit if the command failed
+ Error("Sonar analysis finalization failed. Error:\n{0}", string.Join(Environment.NewLine, error));
+ Environment.Exit(255);
+ }
+ });
diff --git a/NETCore.Keycloak.Client.Tests/requirments.txt b/NETCore.Keycloak.Client.Tests/requirements.txt
similarity index 100%
rename from NETCore.Keycloak.Client.Tests/requirments.txt
rename to NETCore.Keycloak.Client.Tests/requirements.txt
diff --git a/README.md b/README.md
index 5d38c33..62c380a 100644
--- a/README.md
+++ b/README.md
@@ -11,12 +11,23 @@
-[](https://github.com/Black-Cockpit/NETCore.Keycloak/actions/workflows/build.yml)
+[](https://github.com/Black-Cockpit/NETCore.Keycloak/actions/workflows/build.yml)
[](https://www.nuget.org/packages/Keycloak.NETCore.Client/)
[](https://www.nuget.org/packages/Keycloak.NETCore.Client/)
[](https://github.com/Black-Cockpit/NETCore.Keycloak/stargazers)
[](https://www.codefactor.io/repository/github/black-cockpit/netcore.keycloak)
[](https://app.fossa.com/projects/git%2Bgithub.com%2FBlack-Cockpit%2FNETCore.Keycloak?ref=badge_shield&issueType=security)
+[](https://sonarcloud.io/summary/new_code?id=Black-Cockpit_NETCore.Keycloak)
+[](https://sonarcloud.io/summary/new_code?id=Black-Cockpit_NETCore.Keycloak)
+[](https://sonarcloud.io/summary/new_code?id=Black-Cockpit_NETCore.Keycloak)
+[](https://sonarcloud.io/summary/new_code?id=Black-Cockpit_NETCore.Keycloak)
+[](https://sonarcloud.io/summary/new_code?id=Black-Cockpit_NETCore.Keycloak)
+[](https://sonarcloud.io/summary/new_code?id=Black-Cockpit_NETCore.Keycloak)
+[](https://sonarcloud.io/summary/new_code?id=Black-Cockpit_NETCore.Keycloak)
+[](https://sonarcloud.io/summary/new_code?id=Black-Cockpit_NETCore.Keycloak)
+[](https://sonarcloud.io/summary/new_code?id=Black-Cockpit_NETCore.Keycloak)
+[](https://sonarcloud.io/summary/new_code?id=Black-Cockpit_NETCore.Keycloak)
+[](https://sonarcloud.io/summary/new_code?id=Black-Cockpit_NETCore.Keycloak)
[](LICENSE)
[](https://app.fossa.com/projects/git%2Bgithub.com%2FBlack-Cockpit%2FNETCore.Keycloak?ref=badge_shield&issueType=license)