From 9cf99bb9af8517ac47e9c049d556fdfb70bff0f3 Mon Sep 17 00:00:00 2001 From: Coen van den Munckhof Date: Wed, 4 Sep 2024 21:21:48 +0200 Subject: [PATCH] Update azure templates not to run sonar cloud tasks when the build is a pull request comming from a fork --- .azuredevops/Pipelines/Templates/prepare-code-analysis.yaml | 4 +++- .azuredevops/Pipelines/Templates/publish-code-analysis.yaml | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.azuredevops/Pipelines/Templates/prepare-code-analysis.yaml b/.azuredevops/Pipelines/Templates/prepare-code-analysis.yaml index d2428587..d261d5c4 100644 --- a/.azuredevops/Pipelines/Templates/prepare-code-analysis.yaml +++ b/.azuredevops/Pipelines/Templates/prepare-code-analysis.yaml @@ -9,4 +9,6 @@ steps: projectName: RepoM extraProperties: | sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/**/*.trx - sonar.cs.opencover.reportsPaths=$(Agent.TempDirectory)/**/*.opencover.xml \ No newline at end of file + sonar.cs.opencover.reportsPaths=$(Agent.TempDirectory)/**/*.opencover.xml + condition: or( ne(variables['Build.Reason'], 'PullRequest'), eq(variables['System.PullRequest.IsFork'], 'false') ) + \ No newline at end of file diff --git a/.azuredevops/Pipelines/Templates/publish-code-analysis.yaml b/.azuredevops/Pipelines/Templates/publish-code-analysis.yaml index 9e5a9e65..8e6deaa0 100644 --- a/.azuredevops/Pipelines/Templates/publish-code-analysis.yaml +++ b/.azuredevops/Pipelines/Templates/publish-code-analysis.yaml @@ -2,9 +2,11 @@ steps: - task: SonarCloudAnalyze@2 displayName: ⚙️ Run Code Analysis + condition: or( ne(variables['Build.Reason'], 'PullRequest'), eq(variables['System.PullRequest.IsFork'], 'false') ) - task: SonarCloudPublish@2 displayName: 📢 Publish Quality Gate Result + condition: or( ne(variables['Build.Reason'], 'PullRequest'), eq(variables['System.PullRequest.IsFork'], 'false') ) - pwsh: | dotnet tool install --tool-path . dotnet-reportgenerator-globaltool