Validate pipeline commit matches resource in vpack publish (#2425)

* Validate branch when publishing

* Yml fix

* Another try

* Just move to templates

* 1 more fix

* Keep trying

* Just put it in prepare

* Another try

* Better validation
This commit is contained in:
Thad House 2022-02-24 09:48:34 -08:00 коммит произвёл GitHub
Родитель f9f131d11e
Коммит f6df9317bb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 35 добавлений и 0 удалений

Просмотреть файл

@ -14,6 +14,12 @@ jobs:
- name: runCodesignValidationInjection
value: false
steps:
- task: Powershell@2
displayName: Validate package commits
inputs:
pwsh: true
filePath: scripts/validate-package-commits.ps1
arguments: -ResourceCommit $(resources.pipeline.onebranch.sourceCommit) -ResourceBranch $(resources.pipeline.onebranch.sourceBranch) -PipelineCommit $(Build.SourceVersion) -PipelineBranch $(Build.SourceBranch)
- template: ./download-artifacts.yml
parameters:
platform: winkernel

Просмотреть файл

@ -0,0 +1,29 @@
param (
[Parameter(Mandatory = $true)]
[string]$ResourceCommit,
[Parameter(Mandatory = $true)]
[string]$ResourceBranch,
[Parameter(Mandatory = $true)]
[string]$PipelineCommit,
[Parameter(Mandatory = $true)]
[string]$PipelineBranch
)
$Failed = $false
if ($ResourceCommit -ne $PipelineCommit) {
Write-Host "##vso[task.LogIssue type=error;]Mismatched commits. Resource: $ResourceCommit Pipeline: $PipelineCommit"
$Failed = $true
}
if ($ResourceBranch -ne $PipelineBranch) {
Write-Host "##vso[task.LogIssue type=error;]Mismatched branches. Resource: $ResourceBranch Pipeline: $PipelineBranch"
$Failed = $true
}
if ($Failed) {
exit 1
}