From 85e823fe59cd858ada07da15ccf389ff790f4949 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Mon, 27 Apr 2026 14:37:28 +0200 Subject: [PATCH 1/2] [devops] Remove empty directories before archiving HTML reports Empty directories in jenkins-results add noise to the HtmlReport.zip archives. Remove them before the ArchiveFiles task runs. - tests/run-tests.yml and mac/build.yml: use find -empty -delete (bash/macOS) - windows/build.yml: use PowerShell equivalent Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tools/devops/automation/templates/mac/build.yml | 8 ++++++++ .../automation/templates/tests/run-tests.yml | 8 ++++++++ .../automation/templates/windows/build.yml | 16 ++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/tools/devops/automation/templates/mac/build.yml b/tools/devops/automation/templates/mac/build.yml index a6c20308996..89180547613 100644 --- a/tools/devops/automation/templates/mac/build.yml +++ b/tools/devops/automation/templates/mac/build.yml @@ -223,6 +223,14 @@ steps: continueOnError: true condition: succeededOrFailed() +# Remove empty directories before archiving. +- bash: | + set -x + find "$(BUILD_REPOSITORY_TITLE)/jenkins-results" -type d -empty -delete || true + displayName: 'Remove empty directories from HtmlReport' + continueOnError: true + condition: succeededOrFailed() + # Archive files for the Html Report so that the report can be easily uploaded as artifacts of the build. - task: ArchiveFiles@1 displayName: 'Archive HtmlReport' diff --git a/tools/devops/automation/templates/tests/run-tests.yml b/tools/devops/automation/templates/tests/run-tests.yml index 55f5d8d5a7b..94afd665850 100644 --- a/tools/devops/automation/templates/tests/run-tests.yml +++ b/tools/devops/automation/templates/tests/run-tests.yml @@ -217,6 +217,14 @@ steps: continueOnError: true condition: and(ne(variables['VSTS_XML_FILES'], 0), succeededOrFailed()) +# Remove empty directories before archiving. +- bash: | + set -x + find "$(BUILD_REPOSITORY_TITLE)/jenkins-results" -type d -empty -delete || true + displayName: 'Remove empty directories from HtmlReport' + continueOnError: true + condition: succeededOrFailed() + # Archive files for the Html Report so that the report can be easily uploaded as artifacts of the build. - task: ArchiveFiles@1 displayName: 'Archive HtmlReport' diff --git a/tools/devops/automation/templates/windows/build.yml b/tools/devops/automation/templates/windows/build.yml index 7145baec4ee..3d11c215f2a 100644 --- a/tools/devops/automation/templates/windows/build.yml +++ b/tools/devops/automation/templates/windows/build.yml @@ -357,6 +357,22 @@ steps: continueOnError: true condition: succeededOrFailed() +# Remove empty directories before archiving. +- pwsh: | + $root = "$(Build.SourcesDirectory)/$(BUILD_REPOSITORY_TITLE)/jenkins-results" + if (Test-Path $root) { + Get-ChildItem $root -Recurse -Force -Directory | + Sort-Object -Property FullName -Descending | + Where-Object { ($_ | Get-ChildItem -Force | Select-Object -First 1).Count -eq 0 } | + ForEach-Object { + Write-Host "Removing empty directory: $($_.FullName)" + Remove-Item -Force $_ + } + } + displayName: 'Remove empty directories from HtmlReport' + continueOnError: true + condition: succeededOrFailed() + # Archive files for the Html Report so that the report can be easily uploaded as artifacts of the build. - task: ArchiveFiles@1 displayName: 'Archive HtmlReport' From 3152b8d9be806a06d162c6145d6c7d86aa5a424f Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Mon, 27 Apr 2026 15:44:15 +0200 Subject: [PATCH 2/2] [devops] Extract archive-html-report.yml shared template The remove-empty-dirs + archive + publish steps for the HTML report were duplicated across tests/run-tests.yml, mac/build.yml, and windows/build.yml. Extract them into common/archive-html-report.yml with rootFolder and artifactName parameters. Uses pwsh (cross-platform) for the empty directory removal. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../templates/common/archive-html-report.yml | 47 +++++++++++++++++++ .../devops/automation/templates/mac/build.yml | 25 +--------- .../automation/templates/tests/run-tests.yml | 28 +---------- .../automation/templates/windows/build.yml | 36 +------------- 4 files changed, 53 insertions(+), 83 deletions(-) create mode 100644 tools/devops/automation/templates/common/archive-html-report.yml diff --git a/tools/devops/automation/templates/common/archive-html-report.yml b/tools/devops/automation/templates/common/archive-html-report.yml new file mode 100644 index 00000000000..cb4c4fed8f0 --- /dev/null +++ b/tools/devops/automation/templates/common/archive-html-report.yml @@ -0,0 +1,47 @@ +# Remove empty directories, archive the Html Report, and publish it as a pipeline artifact. +parameters: + +- name: rootFolder + type: string + +- name: artifactName + type: string + +steps: + +# Remove empty directories before archiving. +- pwsh: | + $root = "${{ parameters.rootFolder }}" + if (Test-Path $root) { + Get-ChildItem $root -Recurse -Force -Directory | + Sort-Object -Property FullName -Descending | + Where-Object { ($_ | Get-ChildItem -Force | Select-Object -First 1).Count -eq 0 } | + ForEach-Object { + Write-Host "Removing empty directory: $($_.FullName)" + Remove-Item -Force $_ + } + } + displayName: 'Remove empty directories from HtmlReport' + continueOnError: true + condition: succeededOrFailed() + +# Archive files for the Html Report so that the report can be easily uploaded as artifacts of the build. +- task: ArchiveFiles@1 + displayName: 'Archive HtmlReport' + inputs: + rootFolder: '${{ parameters.rootFolder }}' + includeRootFolder: false + archiveFile: '$(Build.ArtifactStagingDirectory)/HtmlReport.zip' + continueOnError: true + condition: succeededOrFailed() + +# Create HtmlReport artifact. This serves two purposes: +# 1. It is the way we are going to share the HtmlReport with the publish_html job that is executed on a Windows machine. +# 2. Users can download this if they want. +- task: PublishPipelineArtifact@1 + displayName: 'Publish Artifact: HtmlReport' + inputs: + targetPath: '$(Build.ArtifactStagingDirectory)/HtmlReport.zip' + artifactName: '${{ parameters.artifactName }}' + continueOnError: true + condition: succeededOrFailed() diff --git a/tools/devops/automation/templates/mac/build.yml b/tools/devops/automation/templates/mac/build.yml index 89180547613..b564d24af9a 100644 --- a/tools/devops/automation/templates/mac/build.yml +++ b/tools/devops/automation/templates/mac/build.yml @@ -223,30 +223,9 @@ steps: continueOnError: true condition: succeededOrFailed() -# Remove empty directories before archiving. -- bash: | - set -x - find "$(BUILD_REPOSITORY_TITLE)/jenkins-results" -type d -empty -delete || true - displayName: 'Remove empty directories from HtmlReport' - continueOnError: true - condition: succeededOrFailed() - -# Archive files for the Html Report so that the report can be easily uploaded as artifacts of the build. -- task: ArchiveFiles@1 - displayName: 'Archive HtmlReport' - inputs: +- template: ../common/archive-html-report.yml + parameters: rootFolder: '$(BUILD_REPOSITORY_TITLE)/jenkins-results' - includeRootFolder: false - archiveFile: '$(Build.ArtifactStagingDirectory)/HtmlReport.zip' - continueOnError: true - condition: succeededOrFailed() - -- task: PublishPipelineArtifact@1 - displayName: 'Publish Artifact: HtmlReport' - inputs: - targetPath: '$(Build.ArtifactStagingDirectory)/HtmlReport.zip' artifactName: '${{ parameters.uploadPrefix }}HtmlReport-${{ parameters.stageName }}${{ parameters.label }}-$(System.JobAttempt)' - continueOnError: true - condition: succeededOrFailed() diff --git a/tools/devops/automation/templates/tests/run-tests.yml b/tools/devops/automation/templates/tests/run-tests.yml index 94afd665850..0ff0d43d39c 100644 --- a/tools/devops/automation/templates/tests/run-tests.yml +++ b/tools/devops/automation/templates/tests/run-tests.yml @@ -217,34 +217,10 @@ steps: continueOnError: true condition: and(ne(variables['VSTS_XML_FILES'], 0), succeededOrFailed()) -# Remove empty directories before archiving. -- bash: | - set -x - find "$(BUILD_REPOSITORY_TITLE)/jenkins-results" -type d -empty -delete || true - displayName: 'Remove empty directories from HtmlReport' - continueOnError: true - condition: succeededOrFailed() - -# Archive files for the Html Report so that the report can be easily uploaded as artifacts of the build. -- task: ArchiveFiles@1 - displayName: 'Archive HtmlReport' - inputs: +- template: ../common/archive-html-report.yml + parameters: rootFolder: '$(BUILD_REPOSITORY_TITLE)/jenkins-results' - includeRootFolder: false - archiveFile: '$(Build.ArtifactStagingDirectory)/HtmlReport.zip' - continueOnError: true - condition: succeededOrFailed() - -# Create HtmlReport artifact. This serves two purposes: -# 1. It is the way we are going to share the HtmlReport with the publish_html job that is executed on a Windows machine. -# 2. Users can download this if they want. -- task: PublishPipelineArtifact@1 - displayName: 'Publish Artifact: HtmlReport' - inputs: - targetPath: '$(Build.ArtifactStagingDirectory)/HtmlReport.zip' artifactName: '${{ parameters.uploadPrefix }}HtmlReport-${{ parameters.testPrefix }}-$(System.JobAttempt)' - continueOnError: true - condition: succeededOrFailed() # Upload all the binlogs # Copy all the binlogs to a separate directory, keeping directory structure. diff --git a/tools/devops/automation/templates/windows/build.yml b/tools/devops/automation/templates/windows/build.yml index 3d11c215f2a..f54bf8a9713 100644 --- a/tools/devops/automation/templates/windows/build.yml +++ b/tools/devops/automation/templates/windows/build.yml @@ -357,42 +357,10 @@ steps: continueOnError: true condition: succeededOrFailed() -# Remove empty directories before archiving. -- pwsh: | - $root = "$(Build.SourcesDirectory)/$(BUILD_REPOSITORY_TITLE)/jenkins-results" - if (Test-Path $root) { - Get-ChildItem $root -Recurse -Force -Directory | - Sort-Object -Property FullName -Descending | - Where-Object { ($_ | Get-ChildItem -Force | Select-Object -First 1).Count -eq 0 } | - ForEach-Object { - Write-Host "Removing empty directory: $($_.FullName)" - Remove-Item -Force $_ - } - } - displayName: 'Remove empty directories from HtmlReport' - continueOnError: true - condition: succeededOrFailed() - -# Archive files for the Html Report so that the report can be easily uploaded as artifacts of the build. -- task: ArchiveFiles@1 - displayName: 'Archive HtmlReport' - inputs: +- template: ../common/archive-html-report.yml + parameters: rootFolder: '$(Build.SourcesDirectory)/$(BUILD_REPOSITORY_TITLE)/jenkins-results' - includeRootFolder: false - archiveFile: '$(Build.ArtifactStagingDirectory)/HtmlReport.zip' - continueOnError: true - condition: succeededOrFailed() - -# Create HtmlReport artifact. This serves two purposes: -# 1. It is the way we are going to share the HtmlReport with the publish_html job that is executed on a Windows machine. -# 2. Users can download this if they want. -- task: PublishPipelineArtifact@1 - displayName: 'Publish Artifact: HtmlReport' - inputs: - targetPath: '$(Build.ArtifactStagingDirectory)/HtmlReport.zip' artifactName: '${{ parameters.uploadPrefix }}HtmlReport-windows_integrationwindows-$(System.JobAttempt)' - continueOnError: true - condition: succeededOrFailed() - pwsh: | Write-Host "Run windows tests."