From acc1ee57557d68ec4ed2d1fb7b23d5471fccb0e9 Mon Sep 17 00:00:00 2001 From: Ben Broderick Phillips Date: Mon, 4 Mar 2024 17:32:37 -0500 Subject: [PATCH 1/5] Run publish on failed or succeeded --- eng/common/pipelines/templates/steps/publish-1es-artifact.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/pipelines/templates/steps/publish-1es-artifact.yml b/eng/common/pipelines/templates/steps/publish-1es-artifact.yml index b06b2d0e444c..4a7cac8d92bc 100644 --- a/eng/common/pipelines/templates/steps/publish-1es-artifact.yml +++ b/eng/common/pipelines/templates/steps/publish-1es-artifact.yml @@ -23,7 +23,7 @@ steps: displayName: Set Failed Artifact Name - task: 1ES.PublishPipelineArtifact@1 - condition: and(succeeded(), ${{ parameters.CustomCondition }}) + condition: and(failedOrSucceeded(), ${{ parameters.CustomCondition }}) displayName: 'Publish ${{ parameters.ArtifactName }} Artifacts' inputs: artifact: '$(PublishArtifactName)' From 54a7e7d08b48abf25dc7c0440441d681c3014411 Mon Sep 17 00:00:00 2001 From: Ben Broderick Phillips Date: Mon, 4 Mar 2024 21:27:39 -0500 Subject: [PATCH 2/5] Expand agent os string detection --- eng/common/scripts/Verify-AgentOS.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/common/scripts/Verify-AgentOS.ps1 b/eng/common/scripts/Verify-AgentOS.ps1 index 3839553a0ff7..e67c5e5aa2b9 100644 --- a/eng/common/scripts/Verify-AgentOS.ps1 +++ b/eng/common/scripts/Verify-AgentOS.ps1 @@ -10,9 +10,9 @@ function Throw-InvalidOperatingSystem { if ($IsWindows -and $AgentImage -match "windows|win|MMS\d{4}") { $osName = "Windows" -} elseif ($IsLinux -and $AgentImage -match "ubuntu") { +} elseif ($IsLinux -and $AgentImage -match "ubuntu|linux") { $osName = "Linux" -} elseif ($IsMacOs -and $AgentImage -match "macos") { +} elseif ($IsMacOs -and $AgentImage -match "macos|macOS") { $osName = "macOS" } else { Throw-InvalidOperatingSystem From b4cc11fe5d3b52d1f0ba549488ffa69178913d5e Mon Sep 17 00:00:00 2001 From: Ben Broderick Phillips Date: Mon, 4 Mar 2024 21:30:54 -0500 Subject: [PATCH 3/5] Check agent job status env var for artifact name detection --- .../templates/steps/publish-1es-artifact.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/eng/common/pipelines/templates/steps/publish-1es-artifact.yml b/eng/common/pipelines/templates/steps/publish-1es-artifact.yml index 4a7cac8d92bc..66e13ee79277 100644 --- a/eng/common/pipelines/templates/steps/publish-1es-artifact.yml +++ b/eng/common/pipelines/templates/steps/publish-1es-artifact.yml @@ -13,17 +13,16 @@ parameters: steps: - pwsh: | - Write-Host "##vso[task.setvariable variable=PublishArtifactName;]${{ parameters.ArtifactName }}" - condition: and(succeeded(), ${{ parameters.CustomCondition }}) - displayName: Set Artifact Name - - - pwsh: | - Write-Host "##vso[task.setvariable variable=PublishArtifactName;]${{ parameters.ArtifactName }}-FailedAttempt$(System.JobAttempt)" + if ($env:AGENT_JOBSTATUS -eq "Failed") { + Write-Host "##vso[task.setvariable variable=PublishArtifactName;]${{ parameters.ArtifactName }}-FailedAttempt$(System.JobAttempt)" + } else { + Write-Host "##vso[task.setvariable variable=PublishArtifactName;]${{ parameters.ArtifactName }}" + } condition: and(failed(), ${{ parameters.CustomCondition }}) - displayName: Set Failed Artifact Name + displayName: Set Artifact Name $(Agent.JobStatus) - task: 1ES.PublishPipelineArtifact@1 - condition: and(failedOrSucceeded(), ${{ parameters.CustomCondition }}) + condition: and(succeededOrFailed(), ${{ parameters.CustomCondition }}) displayName: 'Publish ${{ parameters.ArtifactName }} Artifacts' inputs: artifact: '$(PublishArtifactName)' From bc03c53d9ee652c8f57a41f526e6e9401f77b703 Mon Sep 17 00:00:00 2001 From: Ben Broderick Phillips Date: Tue, 5 Mar 2024 14:40:20 -0500 Subject: [PATCH 4/5] Add sbomEnabled flag to publish template --- .../pipelines/templates/steps/publish-1es-artifact.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/eng/common/pipelines/templates/steps/publish-1es-artifact.yml b/eng/common/pipelines/templates/steps/publish-1es-artifact.yml index 66e13ee79277..a8ebae6d738b 100644 --- a/eng/common/pipelines/templates/steps/publish-1es-artifact.yml +++ b/eng/common/pipelines/templates/steps/publish-1es-artifact.yml @@ -5,11 +5,13 @@ # ArtifactName - The name of the artifact in the "successful" case. # ArtifactPath - The path we will be publishing. # CustomCondition - Used if there is additional logic necessary to prevent attempt of publish. +# SbomEnabled - Set whether to auto-inject 1es pipeline template sbom tasks parameters: ArtifactName: '' ArtifactPath: '' CustomCondition: true + SbomEnabled: true steps: - pwsh: | @@ -25,5 +27,6 @@ steps: condition: and(succeededOrFailed(), ${{ parameters.CustomCondition }}) displayName: 'Publish ${{ parameters.ArtifactName }} Artifacts' inputs: - artifact: '$(PublishArtifactName)' - path: '${{ parameters.ArtifactPath }}' + artifactName: '$(PublishArtifactName)' + targetPath: '${{ parameters.ArtifactPath }}' + sbomEnabled: ${{ parameters.SbomEnabled }} From bc271caf19549093f9504c823ccf5a1b835e7f09 Mon Sep 17 00:00:00 2001 From: Ben Broderick Phillips Date: Tue, 5 Mar 2024 16:37:28 -0500 Subject: [PATCH 5/5] Fix image and artifact name conditional --- eng/common/pipelines/templates/jobs/generate-job-matrix.yml | 2 +- eng/common/pipelines/templates/steps/publish-1es-artifact.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/common/pipelines/templates/jobs/generate-job-matrix.yml b/eng/common/pipelines/templates/jobs/generate-job-matrix.yml index 67ee92a93839..a7459e6b5db5 100644 --- a/eng/common/pipelines/templates/jobs/generate-job-matrix.yml +++ b/eng/common/pipelines/templates/jobs/generate-job-matrix.yml @@ -66,7 +66,7 @@ jobs: value: $[ coalesce(variables.jobMatrixFilter, '.*') ] pool: name: ${{ parameters.Pool }} - vmImage: ${{ parameters.OsVmImage }} + image: ${{ parameters.OsVmImage }} os: ${{ parameters.Os }} ${{ if parameters.DependsOn }}: dependsOn: ${{ parameters.DependsOn }} diff --git a/eng/common/pipelines/templates/steps/publish-1es-artifact.yml b/eng/common/pipelines/templates/steps/publish-1es-artifact.yml index a8ebae6d738b..7648a34165f7 100644 --- a/eng/common/pipelines/templates/steps/publish-1es-artifact.yml +++ b/eng/common/pipelines/templates/steps/publish-1es-artifact.yml @@ -20,7 +20,7 @@ steps: } else { Write-Host "##vso[task.setvariable variable=PublishArtifactName;]${{ parameters.ArtifactName }}" } - condition: and(failed(), ${{ parameters.CustomCondition }}) + condition: and(succeededOrFailed(), ${{ parameters.CustomCondition }}) displayName: Set Artifact Name $(Agent.JobStatus) - task: 1ES.PublishPipelineArtifact@1