From e246a83b82d65384bcec7e230f2d251ceaf4a22b Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Wed, 19 May 2021 08:22:38 -0400 Subject: [PATCH] [CI] Update the config and parse it in the cascade pipeline. (#11587) --- .../automation/templates/build/configure.yml | 8 ++++++++ .../templates/publish-html-result.yml | 19 +++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/tools/devops/automation/templates/build/configure.yml b/tools/devops/automation/templates/build/configure.yml index d33904db86..8da12de982 100644 --- a/tools/devops/automation/templates/build/configure.yml +++ b/tools/devops/automation/templates/build/configure.yml @@ -25,6 +25,14 @@ steps: BuildId = "$(Build.BuildId)" } + # calculate the commit to later share it with the cascade pipelines + if ($Env:BUILD_REASON -eq "PullRequest") { + $changeId = $configuration.BuildSourceBranch.Replace("refs/pull/", "").Replace("/merge", "") + } else { + $changeId = $Env:BUILD_REVISION + } + + $configuration | Add-Member -NotePropertyName Commit -NotePropertyValue $changeId Write-Host "buildReason: $($configuration.BuildReason)" Write-Host "buildSourceBranchName: $($configuration.BuildSourceBranchName)" diff --git a/tools/devops/automation/templates/publish-html-result.yml b/tools/devops/automation/templates/publish-html-result.yml index 998c48efa6..12904bdc0c 100644 --- a/tools/devops/automation/templates/publish-html-result.yml +++ b/tools/devops/automation/templates/publish-html-result.yml @@ -10,9 +10,24 @@ steps: - checkout: self persistCredentials: true +# download the json that contains all the info that triggered this build +- task: DownloadPipelineArtifact@2 + displayName: Download configuration.json + inputs: + patterns: '**/configuration.json' + allowFailedBuilds: true + path: $(Build.SourcesDirectory)/build-configuration + - pwsh: | - Write-Host "Work in progress" - displayName: 'Remove logs' + $configFile = Join-Path $(Build.SourcesDirectory) build-configuration + $config = Get-Content $configFile | ConvertFrom-Json + # export variables to be present in the othe steps + Write-Host "##vso[task.setvariable variable=BuildSourceBranchName;isOutput=true]$($config.BuildSourceBranchName)" + Write-Host "##vso[task.setvariable variable=BuildSourceBranch;isOutput=true]$($config.BuildSourceBranch)" + Write-Host "##vso[task.setvariable variable=BuildId;isOutput=true]$($config.BuildId)" + Write-Host "##vso[task.setvariable variable=Commit;isOutput=true]$($config.Commit)" + name: configuration + displayName: 'Parse build configuration' timeoutInMinutes: 1 - pwsh: |