Skip to content

Commit

Permalink
Save the pull request number into pipeline result (Azure#21059)
Browse files Browse the repository at this point in the history
  • Loading branch information
wyunchi-ms authored Mar 1, 2023
1 parent fe15edd commit 89719d4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .azure-pipelines/util/test-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
<BuildAction Condition="'$(Configuration)' == 'Release'">publish</BuildAction>
</PropertyGroup>

<Exec Command="$(PowerShellCoreCommandPrefix) &quot;.\tools\ExecuteCIStep.ps1 -Build -RepoArtifacts $(RepoArtifacts) -Configuration $(Configuration) -GenerateDocumentationFile $(GenerateDocumentationFile) -EnableTestCoverage $(TurnOnTestCoverage) -BuildAction $(BuildAction)&quot;" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;.\tools\ExecuteCIStep.ps1 -Build -PullRequestNumber $(PullRequestNumber) -RepoArtifacts $(RepoArtifacts) -Configuration $(Configuration) -GenerateDocumentationFile $(GenerateDocumentationFile) -EnableTestCoverage $(TurnOnTestCoverage) -BuildAction $(BuildAction)&quot;" />

<!-- Build version controller -->
<Exec Command="dotnet build $(RepoTools)VersionController/VersionController.Netcore.csproj -c $(Configuration)" />
Expand Down
4 changes: 4 additions & 0 deletions tools/ExecuteCIStep.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Param(
[String]
$BuildAction='build',

[String]
$PullRequestNumber,

[String]
$GenerateDocumentationFile,

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tools/StaticAnalysis/CollectStaticAnalysisPipelineResult.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
}
Expand Down

0 comments on commit 89719d4

Please sign in to comment.