From 89719d4db9aac5c34bc7821bd6f1d391971d738a Mon Sep 17 00:00:00 2001
From: Yunchi Wang <54880216+wyunchi-ms@users.noreply.github.com>
Date: Wed, 1 Mar 2023 13:46:15 +0800
Subject: [PATCH] Save the pull request number into pipeline result (#21059)
---
.azure-pipelines/util/test-steps.yml | 2 ++
build.proj | 2 +-
tools/ExecuteCIStep.ps1 | 4 ++++
.../StaticAnalysis/CollectStaticAnalysisPipelineResult.ps1 | 6 +++---
4 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/.azure-pipelines/util/test-steps.yml b/.azure-pipelines/util/test-steps.yml
index 270c08d799ef..d1f356d3283c 100644
--- a/.azure-pipelines/util/test-steps.yml
+++ b/.azure-pipelines/util/test-steps.yml
@@ -67,6 +67,8 @@ steps:
displayName: 'Test for AutoGen Modules With PowerShell Core'
condition: and(succeeded(), eq('${{ parameters.testTarget }}', 'Test'))
continueOnError: true
+ env:
+ PowerShellPlatform: ${{ parameters.powerShellPlatform }}
- pwsh: |
$PipelineResult = Get-Content PipelineResult.json | ConvertFrom-Json
diff --git a/build.proj b/build.proj
index 357c6364a88e..0f4a332f4767 100644
--- a/build.proj
+++ b/build.proj
@@ -198,7 +198,7 @@
publish
-
+
diff --git a/tools/ExecuteCIStep.ps1 b/tools/ExecuteCIStep.ps1
index 0d42b06e8b90..de009dea2056 100644
--- a/tools/ExecuteCIStep.ps1
+++ b/tools/ExecuteCIStep.ps1
@@ -23,6 +23,9 @@ Param(
[String]
$BuildAction='build',
+ [String]
+ $PullRequestNumber,
+
[String]
$GenerateDocumentationFile,
@@ -258,6 +261,7 @@ If ($Build)
}
$Template.$DependencyStep.Details += $Detail
}
+ $Template | Add-Member -NotePropertyName pull_request_number -NotePropertyValue $PullRequestNumber
ConvertTo-Json -Depth 10 -InputObject $Template | Out-File -FilePath "$RepoArtifacts/PipelineResult/PipelineResult.json"
#EndRegion
diff --git a/tools/StaticAnalysis/CollectStaticAnalysisPipelineResult.ps1 b/tools/StaticAnalysis/CollectStaticAnalysisPipelineResult.ps1
index e2360325fdcc..7eb1357843ec 100644
--- a/tools/StaticAnalysis/CollectStaticAnalysisPipelineResult.ps1
+++ b/tools/StaticAnalysis/CollectStaticAnalysisPipelineResult.ps1
@@ -36,7 +36,7 @@ Else {
$Platform = "$($Env:PowerShellPlatform) - $OS"
$Template = Get-Content "$ArtifactPipelineInfoFolder/PipelineResult.json" | ConvertFrom-Json
-$DependencyStepList = $Template | Get-Member -MemberType NoteProperty | Select-Object -ExpandProperty Name | Where-Object { $_ -Ne "build" -And $_ -Ne "test" }
+$DependencyStepList = $Template | Get-Member -MemberType NoteProperty | Select-Object -ExpandProperty Name | Where-Object { $_ -Ne "build" -And $_ -Ne "test" -And $_ -Ne "pull_request_number" }
ForEach ($Step In $DependencyStepList) {
If ($Template.$Step.Details.Length -Ne 0) {
$Template.$Step.Details[0] | Add-Member -NotePropertyName Platform -NotePropertyValue $Platform -Force
@@ -145,7 +145,7 @@ ForEach ($Step In $Steps) {
$Content = "|Type|Cmdlet|Example|Line|RuleName|Description|Extent|Remediation|`n|---|---|---|---|---|---|---|---|`n"
}
ElseIf ($PhaseName -Eq "ux") {
- $Content = "|Type|Module|ResourceType|SubResourceType|Command|Description|Remediation|`n|---|---|---|---|---|---|---|`n"
+ $Content = "|Type|Module|ResourceType|SubResourceType|Command|Description|`n|---|---|---|---|---|---|`n"
}
#EndRegion
@@ -164,7 +164,7 @@ ForEach ($Step In $Steps) {
$Content += "|$ErrorTypeEmoji|$($Issue.Target)|$($Issue.Example)|$($Issue.Line)|$($Issue.RuleName)|$($Issue.Description)|$($Issue.Extent)|$($Issue.Remediation)|`n"
}
ElseIf ($PhaseName -Eq "ux") {
- $Content = "|$ErrorTypeEmoji|$($Issue.Module)|$($Issue.ResourceType)|$($Issue.SubResourceType)|$($Issue.Command)|$($Issue.Description)|$($Issue.Remediation)|`n"
+ $Content += "|$ErrorTypeEmoji|$($Issue.Module)|$($Issue.ResourceType)|$($Issue.SubResourceType)|$($Issue.Command)|$($Issue.Description)|`n"
}
#EndRegion
}