From d24fd80e935b68169e13a8510e55468503780f0b Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Tue, 28 Oct 2025 10:52:48 -0700 Subject: [PATCH 01/17] Test skiping of Build and Live tests using runtime variables --- eng/pipelines/templates/jobs/build.yml | 2 +- eng/pipelines/templates/jobs/initialize.yml | 16 ++++++++++++++++ eng/pipelines/templates/jobs/live-test.yml | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/eng/pipelines/templates/jobs/build.yml b/eng/pipelines/templates/jobs/build.yml index 7fe6eaac7b..c0248a646a 100644 --- a/eng/pipelines/templates/jobs/build.yml +++ b/eng/pipelines/templates/jobs/build.yml @@ -16,7 +16,7 @@ parameters: jobs: - job: Build_${{ parameters.OSName }} displayName: "Build" - condition: and(succeeded(), ne(${{ parameters.Matrix }}, '{}')) + condition: and(succeeded(), ne(${{ parameters.Matrix }}, '{}'), ne(variables['SkipBuildJob'], 'true')) strategy: maxParallel: ${{ parameters.MaxParallel }} matrix: $[ ${{ parameters.Matrix }} ] diff --git a/eng/pipelines/templates/jobs/initialize.yml b/eng/pipelines/templates/jobs/initialize.yml index 29f7f5c8d2..98c833817f 100644 --- a/eng/pipelines/templates/jobs/initialize.yml +++ b/eng/pipelines/templates/jobs/initialize.yml @@ -15,6 +15,22 @@ jobs: - checkout: self fetchDepth: 0 + - task: PowerShell@2 + displayName: "Set PR skip job variables" + condition: eq(variables['Build.Reason'], 'PullRequest') + inputs: + pwsh: true + targetType: 'inline' + script: | + Write-Host "Setting pipeline variables for PR build" + + # Set pipeline variables that can be used in subsequent stages + Write-Host "##vso[task.setvariable variable=SkipBuildJob;isOutput=true]true" + Write-Host "##vso[task.setvariable variable=SkipLiveTestJob;isOutput=true]true" + + Write-Host "SkipBuildJob set to: true" + Write-Host "SkipLiveTestJob set to: true" + - task: UseDotNet@2 displayName: "Use .NET SDK from global.json" retryCountOnTaskFailure: 3 diff --git a/eng/pipelines/templates/jobs/live-test.yml b/eng/pipelines/templates/jobs/live-test.yml index 04b0f3d3ac..5c2542e931 100644 --- a/eng/pipelines/templates/jobs/live-test.yml +++ b/eng/pipelines/templates/jobs/live-test.yml @@ -11,7 +11,7 @@ jobs: displayName: "Live tests -" timeoutInMinutes: ${{ parameters.TimeoutInMinutes }} # The variable reference in the matrix parameter will resolve to a json map. If there are no live test legs, it will be an empty map. - condition: and(succeeded(), ne(${{ parameters.Matrix }}, '{}')) + condition: and(succeeded(), ne(${{ parameters.Matrix }}, '{}'), ne(variables['SkipLiveTestJob'], 'true')) strategy: maxParallel: ${{ parameters.MaxParallel }} matrix: $[ ${{ parameters.Matrix }} ] From 7e45e15acf3588521e321134ab8c33552bfbe119 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Tue, 28 Oct 2025 11:09:13 -0700 Subject: [PATCH 02/17] Detect the changed files in the pull request --- eng/pipelines/templates/jobs/initialize.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/eng/pipelines/templates/jobs/initialize.yml b/eng/pipelines/templates/jobs/initialize.yml index 98c833817f..4589063295 100644 --- a/eng/pipelines/templates/jobs/initialize.yml +++ b/eng/pipelines/templates/jobs/initialize.yml @@ -22,7 +22,13 @@ jobs: pwsh: true targetType: 'inline' script: | - Write-Host "Setting pipeline variables for PR build" + $changedFilesScriptPath = "$(Build.SourcesDirectory)/eng/common/scripts/get-changedfiles.ps1" + $changedFiles = & $changedFilesScriptPath -DiffFilterType '' + + if ($changedFiles) { + Write-Host "Changed files in this PR : ($($changedFiles.Count)):" + $changedFiles | ForEach-Object { Write-Host " $_" } + } # Set pipeline variables that can be used in subsequent stages Write-Host "##vso[task.setvariable variable=SkipBuildJob;isOutput=true]true" From 3700382f3aa5b0bc6eccc1df46d9135c02780fcd Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Tue, 28 Oct 2025 11:28:47 -0700 Subject: [PATCH 03/17] Skip Build and test based oin chaged files --- eng/pipelines/templates/jobs/build.yml | 2 +- eng/pipelines/templates/jobs/initialize.yml | 59 ++++++++++++++++++--- eng/pipelines/templates/jobs/live-test.yml | 2 +- 3 files changed, 53 insertions(+), 10 deletions(-) diff --git a/eng/pipelines/templates/jobs/build.yml b/eng/pipelines/templates/jobs/build.yml index c0248a646a..b9856d27c7 100644 --- a/eng/pipelines/templates/jobs/build.yml +++ b/eng/pipelines/templates/jobs/build.yml @@ -16,7 +16,7 @@ parameters: jobs: - job: Build_${{ parameters.OSName }} displayName: "Build" - condition: and(succeeded(), ne(${{ parameters.Matrix }}, '{}'), ne(variables['SkipBuildJob'], 'true')) + condition: and(succeeded(), ne(${{ parameters.Matrix }}, '{}'), ne(stageDependencies.Initialize.Initialize.outputs['SetPRSkipJobVariables.SkipBuildJob'], 'true')ne(stageDependencies.Initialize.Initialize.outputs['SetPRSkipJobVariables.SkipBuildJob'], 'true')) strategy: maxParallel: ${{ parameters.MaxParallel }} matrix: $[ ${{ parameters.Matrix }} ] diff --git a/eng/pipelines/templates/jobs/initialize.yml b/eng/pipelines/templates/jobs/initialize.yml index 4589063295..13cd637c68 100644 --- a/eng/pipelines/templates/jobs/initialize.yml +++ b/eng/pipelines/templates/jobs/initialize.yml @@ -17,26 +17,69 @@ jobs: - task: PowerShell@2 displayName: "Set PR skip job variables" + name: SetPRSkipJobVariables condition: eq(variables['Build.Reason'], 'PullRequest') inputs: pwsh: true targetType: 'inline' script: | + # Set of files that don't require build or test when changed + $skipFiles = @( + 'CHANGELOG.md', + 'README.md', + 'SUPPORT.md', + 'TROUBLESHOOTING.md', + 'CONTRIBUTING.md', + 'CODE_OF_CONDUCT.md', + 'SECURITY.md', + 'NOTICE.txt', + 'LICENSE' + ) + + # Set of directories that don't require build or test when changed + $skipDirectories = @( + '.github/', + 'eng/common/' + ) + + $skipBuildAndTest = $true + $changedFilesScriptPath = "$(Build.SourcesDirectory)/eng/common/scripts/get-changedfiles.ps1" $changedFiles = & $changedFilesScriptPath -DiffFilterType '' if ($changedFiles) { - Write-Host "Changed files in this PR : ($($changedFiles.Count)):" - $changedFiles | ForEach-Object { Write-Host " $_" } + $changedFiles | ForEach-Object { + Write-Host "Checking file: $_" + $fileName = [System.IO.Path]::GetFileName($_) + $isSkipFile = $skipFiles -contains $fileName + + $normalizedFile = $_ -replace '\\', '/' + $isInSkipDirectory = $false + foreach ($dir in $skipDirectories) { + if ($normalizedFile.StartsWith($dir, [System.StringComparison]::OrdinalIgnoreCase)) { + $isInSkipDirectory = $true + break + } + } + + Write-Host " -> File: $fileName, IsSkipFile: $isSkipFile, IsInSkipDir: $isInSkipDirectory" + if (-not $isSkipFile -and -not $isInSkipDirectory) { + $skipBuildAndTest = $false + Write-Host " -> This file $_ requires build and test!" + return + } + } } - # Set pipeline variables that can be used in subsequent stages - Write-Host "##vso[task.setvariable variable=SkipBuildJob;isOutput=true]true" - Write-Host "##vso[task.setvariable variable=SkipLiveTestJob;isOutput=true]true" + if ($skipBuildAndTest) { + Write-Host "##vso[task.setvariable variable=SkipBuildJob;isOutput=true]true" + Write-Host "##vso[task.setvariable variable=SkipLiveTestJob;isOutput=true]true" + Write-Host "SkipBuildJob set to: true" + Write-Host "SkipLiveTestJob set to: true" + } else { + Write-Host "This PR contains files that require build and/or test." + } - Write-Host "SkipBuildJob set to: true" - Write-Host "SkipLiveTestJob set to: true" - - task: UseDotNet@2 displayName: "Use .NET SDK from global.json" retryCountOnTaskFailure: 3 diff --git a/eng/pipelines/templates/jobs/live-test.yml b/eng/pipelines/templates/jobs/live-test.yml index 5c2542e931..95626f8fd3 100644 --- a/eng/pipelines/templates/jobs/live-test.yml +++ b/eng/pipelines/templates/jobs/live-test.yml @@ -11,7 +11,7 @@ jobs: displayName: "Live tests -" timeoutInMinutes: ${{ parameters.TimeoutInMinutes }} # The variable reference in the matrix parameter will resolve to a json map. If there are no live test legs, it will be an empty map. - condition: and(succeeded(), ne(${{ parameters.Matrix }}, '{}'), ne(variables['SkipLiveTestJob'], 'true')) + condition: and(succeeded(), ne(${{ parameters.Matrix }}, '{}'), ne(stageDependencies.Initialize.Initialize.outputs['SetPRSkipJobVariables.SkipLiveTestJob'], 'true')) strategy: maxParallel: ${{ parameters.MaxParallel }} matrix: $[ ${{ parameters.Matrix }} ] From ac504d27c18242d54f6bfb57cca265a766bb9b14 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Tue, 28 Oct 2025 12:04:11 -0700 Subject: [PATCH 04/17] Add branch trigger for testing --- eng/pipelines/pullrequest.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/pipelines/pullrequest.yml b/eng/pipelines/pullrequest.yml index 4569280d24..a40c4bf80a 100644 --- a/eng/pipelines/pullrequest.yml +++ b/eng/pipelines/pullrequest.yml @@ -5,6 +5,7 @@ pr: - feature/* - hotfix/* - release/* + - SkipJobsBasedOnFilesChanged trigger: none From 821fbbf42aaaad42962559ed13f8b4e50fa7b05c Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Tue, 28 Oct 2025 13:55:42 -0700 Subject: [PATCH 05/17] Move inline script to file --- eng/pipelines/pullrequest.yml | 1 - eng/pipelines/templates/jobs/build.yml | 2 +- eng/pipelines/templates/jobs/initialize.yml | 59 +------------------ eng/scripts/Set-SkipJobVariables.ps1 | 63 +++++++++++++++++++++ 4 files changed, 65 insertions(+), 60 deletions(-) create mode 100644 eng/scripts/Set-SkipJobVariables.ps1 diff --git a/eng/pipelines/pullrequest.yml b/eng/pipelines/pullrequest.yml index a40c4bf80a..4569280d24 100644 --- a/eng/pipelines/pullrequest.yml +++ b/eng/pipelines/pullrequest.yml @@ -5,7 +5,6 @@ pr: - feature/* - hotfix/* - release/* - - SkipJobsBasedOnFilesChanged trigger: none diff --git a/eng/pipelines/templates/jobs/build.yml b/eng/pipelines/templates/jobs/build.yml index b9856d27c7..db85691aaa 100644 --- a/eng/pipelines/templates/jobs/build.yml +++ b/eng/pipelines/templates/jobs/build.yml @@ -16,7 +16,7 @@ parameters: jobs: - job: Build_${{ parameters.OSName }} displayName: "Build" - condition: and(succeeded(), ne(${{ parameters.Matrix }}, '{}'), ne(stageDependencies.Initialize.Initialize.outputs['SetPRSkipJobVariables.SkipBuildJob'], 'true')ne(stageDependencies.Initialize.Initialize.outputs['SetPRSkipJobVariables.SkipBuildJob'], 'true')) + condition: and(succeeded(), ne(${{ parameters.Matrix }}, '{}'), ne(stageDependencies.Initialize.Initialize.outputs['SetPRSkipJobVariables.SkipBuildJob'], 'true')) strategy: maxParallel: ${{ parameters.MaxParallel }} matrix: $[ ${{ parameters.Matrix }} ] diff --git a/eng/pipelines/templates/jobs/initialize.yml b/eng/pipelines/templates/jobs/initialize.yml index 13cd637c68..a8633c0595 100644 --- a/eng/pipelines/templates/jobs/initialize.yml +++ b/eng/pipelines/templates/jobs/initialize.yml @@ -21,64 +21,7 @@ jobs: condition: eq(variables['Build.Reason'], 'PullRequest') inputs: pwsh: true - targetType: 'inline' - script: | - # Set of files that don't require build or test when changed - $skipFiles = @( - 'CHANGELOG.md', - 'README.md', - 'SUPPORT.md', - 'TROUBLESHOOTING.md', - 'CONTRIBUTING.md', - 'CODE_OF_CONDUCT.md', - 'SECURITY.md', - 'NOTICE.txt', - 'LICENSE' - ) - - # Set of directories that don't require build or test when changed - $skipDirectories = @( - '.github/', - 'eng/common/' - ) - - $skipBuildAndTest = $true - - $changedFilesScriptPath = "$(Build.SourcesDirectory)/eng/common/scripts/get-changedfiles.ps1" - $changedFiles = & $changedFilesScriptPath -DiffFilterType '' - - if ($changedFiles) { - $changedFiles | ForEach-Object { - Write-Host "Checking file: $_" - $fileName = [System.IO.Path]::GetFileName($_) - $isSkipFile = $skipFiles -contains $fileName - - $normalizedFile = $_ -replace '\\', '/' - $isInSkipDirectory = $false - foreach ($dir in $skipDirectories) { - if ($normalizedFile.StartsWith($dir, [System.StringComparison]::OrdinalIgnoreCase)) { - $isInSkipDirectory = $true - break - } - } - - Write-Host " -> File: $fileName, IsSkipFile: $isSkipFile, IsInSkipDir: $isInSkipDirectory" - if (-not $isSkipFile -and -not $isInSkipDirectory) { - $skipBuildAndTest = $false - Write-Host " -> This file $_ requires build and test!" - return - } - } - } - - if ($skipBuildAndTest) { - Write-Host "##vso[task.setvariable variable=SkipBuildJob;isOutput=true]true" - Write-Host "##vso[task.setvariable variable=SkipLiveTestJob;isOutput=true]true" - Write-Host "SkipBuildJob set to: true" - Write-Host "SkipLiveTestJob set to: true" - } else { - Write-Host "This PR contains files that require build and/or test." - } + filePath: $(Build.SourcesDirectory)/eng/scripts/Set-SkipJobVariables.ps1 - task: UseDotNet@2 displayName: "Use .NET SDK from global.json" diff --git a/eng/scripts/Set-SkipJobVariables.ps1 b/eng/scripts/Set-SkipJobVariables.ps1 new file mode 100644 index 0000000000..b5b17abb70 --- /dev/null +++ b/eng/scripts/Set-SkipJobVariables.ps1 @@ -0,0 +1,63 @@ +. "$PSScriptRoot/../common/scripts/common.ps1" +$RepoRoot = $RepoRoot.Path.Replace('\', '/') + +# Set of files that don't require build or test when changed +$skipFiles = @( + 'CHANGELOG.md', + 'README.md', + 'SUPPORT.md', + 'TROUBLESHOOTING.md', + 'CONTRIBUTING.md', + 'CODE_OF_CONDUCT.md', + 'SECURITY.md', + 'NOTICE.txt', + 'LICENSE' +) + +# Set of directories that don't require build or test when changed +$skipDirectories = @( + '.github/', + 'eng/images/', + 'docs', + 'Resources' +) + +$skipBuildAndTest = $true + +$changedFilesScriptPath = "$RepoRoot/eng/common/scripts/get-changedfiles.ps1" +$changedFiles = & $changedFilesScriptPath -DiffFilterType '' + +if ($changedFiles) { + $changedFiles | ForEach-Object { + Write-Host "Checking file: $_" + $fileName = [System.IO.Path]::GetFileName($_) + $isSkipFile = $skipFiles -contains $fileName + + $normalizedFile = $_ -replace '\\', '/' + $relativeFile = $normalizedFile -replace [regex]::Escape($RepoRoot), '' + $relativeFile = $relativeFile.TrimStart('/') + $isInSkipDirectory = $false + foreach ($dir in $skipDirectories) { + if ($relativeFile.StartsWith($dir, [System.StringComparison]::OrdinalIgnoreCase)) { + $isInSkipDirectory = $true + break + } + } + + Write-Host " -> File: $fileName, IsSkipFile: $isSkipFile, IsInSkipDir: $isInSkipDirectory" + if (-not $isSkipFile -and -not $isInSkipDirectory) { + $skipBuildAndTest = $false + Write-Host " -> File: $_ requires build and test!" + return + } + } +} + +if ($skipBuildAndTest) { + Write-Host "##vso[task.setvariable variable=SkipBuildJob;isOutput=true]true" + Write-Host "##vso[task.setvariable variable=SkipLiveTestJob;isOutput=true]true" + Write-Host "SkipBuildJob set to: true" + Write-Host "SkipLiveTestJob set to: true" +} else { + Write-Host "This PR contains files that require build and/or test." +} \ No newline at end of file From df3857cfe4dd207b4a69b9027fd899cb49569760 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Wed, 29 Oct 2025 11:31:46 -0700 Subject: [PATCH 06/17] Check file panths --- eng/scripts/Set-SkipJobVariables.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eng/scripts/Set-SkipJobVariables.ps1 b/eng/scripts/Set-SkipJobVariables.ps1 index b5b17abb70..c537369f87 100644 --- a/eng/scripts/Set-SkipJobVariables.ps1 +++ b/eng/scripts/Set-SkipJobVariables.ps1 @@ -33,7 +33,12 @@ if ($changedFiles) { $fileName = [System.IO.Path]::GetFileName($_) $isSkipFile = $skipFiles -contains $fileName + Write-Host " -> File: $_" + $normalizedFile = $_ -replace '\\', '/' + + Write-Host " -> Normalized File: $normalizedFile" + $relativeFile = $normalizedFile -replace [regex]::Escape($RepoRoot), '' $relativeFile = $relativeFile.TrimStart('/') $isInSkipDirectory = $false From 2cf52d64a00f954308837d219ef5b23ef179809b Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Wed, 29 Oct 2025 17:06:24 -0700 Subject: [PATCH 07/17] Update relative file path --- eng/scripts/Set-SkipJobVariables.ps1 | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/eng/scripts/Set-SkipJobVariables.ps1 b/eng/scripts/Set-SkipJobVariables.ps1 index c537369f87..c2db0da164 100644 --- a/eng/scripts/Set-SkipJobVariables.ps1 +++ b/eng/scripts/Set-SkipJobVariables.ps1 @@ -33,14 +33,10 @@ if ($changedFiles) { $fileName = [System.IO.Path]::GetFileName($_) $isSkipFile = $skipFiles -contains $fileName - Write-Host " -> File: $_" - - $normalizedFile = $_ -replace '\\', '/' - - Write-Host " -> Normalized File: $normalizedFile" - - $relativeFile = $normalizedFile -replace [regex]::Escape($RepoRoot), '' + $relativeFile = $_ -replace [regex]::Escape($RepoRoot), '' $relativeFile = $relativeFile.TrimStart('/') + + Write-Host " -> Relative file path: $relativeFile" $isInSkipDirectory = $false foreach ($dir in $skipDirectories) { if ($relativeFile.StartsWith($dir, [System.StringComparison]::OrdinalIgnoreCase)) { From 4d67e98e0288065fe049edc8d29436440e5b40bc Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Mon, 3 Nov 2025 11:01:06 -0800 Subject: [PATCH 08/17] View file name --- eng/scripts/Set-SkipJobVariables.ps1 | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/eng/scripts/Set-SkipJobVariables.ps1 b/eng/scripts/Set-SkipJobVariables.ps1 index c2db0da164..33cdca6d33 100644 --- a/eng/scripts/Set-SkipJobVariables.ps1 +++ b/eng/scripts/Set-SkipJobVariables.ps1 @@ -31,15 +31,12 @@ if ($changedFiles) { $changedFiles | ForEach-Object { Write-Host "Checking file: $_" $fileName = [System.IO.Path]::GetFileName($_) + Write-Host " -> File name: $fileName" $isSkipFile = $skipFiles -contains $fileName - $relativeFile = $_ -replace [regex]::Escape($RepoRoot), '' - $relativeFile = $relativeFile.TrimStart('/') - - Write-Host " -> Relative file path: $relativeFile" $isInSkipDirectory = $false foreach ($dir in $skipDirectories) { - if ($relativeFile.StartsWith($dir, [System.StringComparison]::OrdinalIgnoreCase)) { + if ($_.StartsWith($dir, [System.StringComparison]::OrdinalIgnoreCase)) { $isInSkipDirectory = $true break } From d4f4da3758d57b0dc2190af2f6f4858ae55b47b1 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Mon, 3 Nov 2025 11:09:31 -0800 Subject: [PATCH 09/17] Remove extralogging --- eng/scripts/Set-SkipJobVariables.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/eng/scripts/Set-SkipJobVariables.ps1 b/eng/scripts/Set-SkipJobVariables.ps1 index 33cdca6d33..8775b8c958 100644 --- a/eng/scripts/Set-SkipJobVariables.ps1 +++ b/eng/scripts/Set-SkipJobVariables.ps1 @@ -31,7 +31,6 @@ if ($changedFiles) { $changedFiles | ForEach-Object { Write-Host "Checking file: $_" $fileName = [System.IO.Path]::GetFileName($_) - Write-Host " -> File name: $fileName" $isSkipFile = $skipFiles -contains $fileName $isInSkipDirectory = $false From 6a193bd1a819880782cced6370a2eb7edca6d449 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Tue, 4 Nov 2025 10:14:30 -0800 Subject: [PATCH 10/17] use foreach loop --- eng/scripts/Set-SkipJobVariables.ps1 | 34 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/eng/scripts/Set-SkipJobVariables.ps1 b/eng/scripts/Set-SkipJobVariables.ps1 index 8775b8c958..fafd57ff8d 100644 --- a/eng/scripts/Set-SkipJobVariables.ps1 +++ b/eng/scripts/Set-SkipJobVariables.ps1 @@ -28,25 +28,25 @@ $changedFilesScriptPath = "$RepoRoot/eng/common/scripts/get-changedfiles.ps1" $changedFiles = & $changedFilesScriptPath -DiffFilterType '' if ($changedFiles) { - $changedFiles | ForEach-Object { - Write-Host "Checking file: $_" - $fileName = [System.IO.Path]::GetFileName($_) - $isSkipFile = $skipFiles -contains $fileName - - $isInSkipDirectory = $false - foreach ($dir in $skipDirectories) { - if ($_.StartsWith($dir, [System.StringComparison]::OrdinalIgnoreCase)) { - $isInSkipDirectory = $true - break + foreach ($file in $changedFiles) { + Write-Host "Checking file: $file" + $fileName = [System.IO.Path]::GetFileName($file) + $isSkipFile = $skipFiles -contains $fileName + + $isInSkipDirectory = $false + foreach ($dir in $skipDirectories) { + if ($file.StartsWith($dir, [System.StringComparison]::OrdinalIgnoreCase)) { + $isInSkipDirectory = $true + break + } } - } - Write-Host " -> File: $fileName, IsSkipFile: $isSkipFile, IsInSkipDir: $isInSkipDirectory" - if (-not $isSkipFile -and -not $isInSkipDirectory) { - $skipBuildAndTest = $false - Write-Host " -> File: $_ requires build and test!" - return - } + Write-Host " -> File: $fileName, IsSkipFile: $isSkipFile, IsInSkipDir: $isInSkipDirectory" + if (-not $isSkipFile -and -not $isInSkipDirectory) { + $skipBuildAndTest = $false + Write-Host " -> File: $file requires build and test!" + return + } } } From f7e529352eb8c6f715f0b179c6e168d6d7d44389 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Thu, 6 Nov 2025 11:46:14 -0800 Subject: [PATCH 11/17] Test return of empty array from Get-PathsToTest --- eng/pipelines/templates/jobs/build.yml | 2 +- eng/pipelines/templates/jobs/initialize.yml | 14 +++++++------- eng/pipelines/templates/jobs/live-test.yml | 2 +- eng/scripts/New-BuildInfo.ps1 | 11 ++++++++--- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/eng/pipelines/templates/jobs/build.yml b/eng/pipelines/templates/jobs/build.yml index db85691aaa..7fe6eaac7b 100644 --- a/eng/pipelines/templates/jobs/build.yml +++ b/eng/pipelines/templates/jobs/build.yml @@ -16,7 +16,7 @@ parameters: jobs: - job: Build_${{ parameters.OSName }} displayName: "Build" - condition: and(succeeded(), ne(${{ parameters.Matrix }}, '{}'), ne(stageDependencies.Initialize.Initialize.outputs['SetPRSkipJobVariables.SkipBuildJob'], 'true')) + condition: and(succeeded(), ne(${{ parameters.Matrix }}, '{}')) strategy: maxParallel: ${{ parameters.MaxParallel }} matrix: $[ ${{ parameters.Matrix }} ] diff --git a/eng/pipelines/templates/jobs/initialize.yml b/eng/pipelines/templates/jobs/initialize.yml index a8633c0595..8ae5f10839 100644 --- a/eng/pipelines/templates/jobs/initialize.yml +++ b/eng/pipelines/templates/jobs/initialize.yml @@ -15,13 +15,13 @@ jobs: - checkout: self fetchDepth: 0 - - task: PowerShell@2 - displayName: "Set PR skip job variables" - name: SetPRSkipJobVariables - condition: eq(variables['Build.Reason'], 'PullRequest') - inputs: - pwsh: true - filePath: $(Build.SourcesDirectory)/eng/scripts/Set-SkipJobVariables.ps1 + #- task: PowerShell@2 + # displayName: "Set PR skip job variables" + # name: SetPRSkipJobVariables + # condition: eq(variables['Build.Reason'], 'PullRequest') + # inputs: + # pwsh: true + # filePath: $(Build.SourcesDirectory)/eng/scripts/Set-SkipJobVariables.ps1 - task: UseDotNet@2 displayName: "Use .NET SDK from global.json" diff --git a/eng/pipelines/templates/jobs/live-test.yml b/eng/pipelines/templates/jobs/live-test.yml index 95626f8fd3..04b0f3d3ac 100644 --- a/eng/pipelines/templates/jobs/live-test.yml +++ b/eng/pipelines/templates/jobs/live-test.yml @@ -11,7 +11,7 @@ jobs: displayName: "Live tests -" timeoutInMinutes: ${{ parameters.TimeoutInMinutes }} # The variable reference in the matrix parameter will resolve to a json map. If there are no live test legs, it will be an empty map. - condition: and(succeeded(), ne(${{ parameters.Matrix }}, '{}'), ne(stageDependencies.Initialize.Initialize.outputs['SetPRSkipJobVariables.SkipLiveTestJob'], 'true')) + condition: and(succeeded(), ne(${{ parameters.Matrix }}, '{}')) strategy: maxParallel: ${{ parameters.MaxParallel }} matrix: $[ ${{ parameters.Matrix }} ] diff --git a/eng/scripts/New-BuildInfo.ps1 b/eng/scripts/New-BuildInfo.ps1 index 04a2e92916..fd90f38400 100644 --- a/eng/scripts/New-BuildInfo.ps1 +++ b/eng/scripts/New-BuildInfo.ps1 @@ -154,6 +154,7 @@ $linuxVmImage = CheckVariable 'LINUXVMIMAGE' $macVmImage = CheckVariable 'MACVMIMAGE' function Get-PathsToTest { + return @() Write-Host "Getting paths to test" # When "core" is modified, include storage and keyVault as the canary service tools. @@ -593,10 +594,14 @@ function Get-ServerMatrix { Push-Location $RepoRoot try { $serverDetails = @(Get-ServerDetails) - $matrices = Get-BuildMatrices $serverDetails $pathsToTest = @(Get-PathsToTest) - $matrices['liveTestMatrix'] = Get-TestMatrix $pathsToTest -TestType 'Live' - $matrices['serverMatrix'] = Get-ServerMatrix $serverDetails + $matrices = [ordered]@{} + + if ($pathsToTest.Count -gt 0) { + $matrices = Get-BuildMatrices $serverDetails + $matrices['liveTestMatrix'] = Get-TestMatrix $pathsToTest -TestType 'Live' + $matrices['serverMatrix'] = Get-ServerMatrix $serverDetails + } # spellchecker: ignore SOURCEVERSION $branch = $isPipelineRun ? (CheckVariable 'BUILD_SOURCEBRANCH') : (git rev-parse --abbrev-ref HEAD) From 3fec5616c060a168d7d8c86fc2466e983ff5acac Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Thu, 6 Nov 2025 14:21:42 -0800 Subject: [PATCH 12/17] Skip Build and Live based on matrix content --- eng/pipelines/templates/common.yml | 53 ++++++++++++++++-------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/eng/pipelines/templates/common.yml b/eng/pipelines/templates/common.yml index c4892c5553..3ed5b94a7e 100644 --- a/eng/pipelines/templates/common.yml +++ b/eng/pipelines/templates/common.yml @@ -66,34 +66,37 @@ extends: jobs: - template: /eng/pipelines/templates/jobs/analyze.yml + - ${{ each os in split('linux|windows|macOS', '|') }}: - - template: /eng/pipelines/templates/jobs/build.yml - parameters: - TestTimeoutInMinutes: 30 - ServerName: ${{ parameters.ServerName }} - PublishTarget: ${{ parameters.PublishTarget }} - OSName: ${{ os }} - Matrix: stageDependencies.Initialize.Initialize.outputs['CreateBuildInfo.${{ os }}BuildMatrix'] - MaxParallel: 4 + - ${{ if ne(stageDependencies.Initialize.Initialize.outputs[format('CreateBuildInfo.{0}BuildMatrix', os)], '') }}: + - template: /eng/pipelines/templates/jobs/build.yml + parameters: + TestTimeoutInMinutes: 30 + ServerName: ${{ parameters.ServerName }} + PublishTarget: ${{ parameters.PublishTarget }} + OSName: ${{ os }} + Matrix: stageDependencies.Initialize.Initialize.outputs['CreateBuildInfo.${{ os }}BuildMatrix'] + MaxParallel: 4 - ${{ if and(eq(variables['System.TeamProject'], 'internal'), eq(parameters.RunLiveTests, 'true')) }}: - - stage: Test - displayName: 'Live test' - dependsOn: - - Initialize - pool: - name: $(LINUXPOOL) - image: $(LINUXVMIMAGE) - os: linux - variables: - - template: /eng/pipelines/templates/variables/image.yml - - template: /eng/pipelines/templates/variables/globals.yml - jobs: - - template: /eng/pipelines/templates/jobs/live-test.yml - parameters: - Matrix: stageDependencies.Initialize.Initialize.outputs['CreateBuildInfo.liveTestMatrix'] - MaxParallel: 10 - TimeoutInMinutes: 75 + - ${{ if ne(stageDependencies.Initialize.Initialize.outputs[CreateBuildInfo.liveTestMatrix], '') }}: + - stage: Test + displayName: 'Live test' + dependsOn: + - Initialize + pool: + name: $(LINUXPOOL) + image: $(LINUXVMIMAGE) + os: linux + variables: + - template: /eng/pipelines/templates/variables/image.yml + - template: /eng/pipelines/templates/variables/globals.yml + jobs: + - template: /eng/pipelines/templates/jobs/live-test.yml + parameters: + Matrix: stageDependencies.Initialize.Initialize.outputs['CreateBuildInfo.liveTestMatrix'] + MaxParallel: 10 + TimeoutInMinutes: 75 - ${{ if ne(parameters.PublishTarget, 'none') }}: # We only sign if we're going to publish From df0f8342d600c071b9e4434b108f91cdc024c699 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Thu, 6 Nov 2025 14:47:16 -0800 Subject: [PATCH 13/17] Skip testing for non code files --- eng/scripts/New-BuildInfo.ps1 | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/eng/scripts/New-BuildInfo.ps1 b/eng/scripts/New-BuildInfo.ps1 index fd90f38400..57735b67a5 100644 --- a/eng/scripts/New-BuildInfo.ps1 +++ b/eng/scripts/New-BuildInfo.ps1 @@ -154,7 +154,6 @@ $linuxVmImage = CheckVariable 'LINUXVMIMAGE' $macVmImage = CheckVariable 'MACVMIMAGE' function Get-PathsToTest { - return @() Write-Host "Getting paths to test" # When "core" is modified, include storage and keyVault as the canary service tools. @@ -209,6 +208,19 @@ function Get-PathsToTest { $isPullRequestBuild = $env:BUILD_REASON -eq 'PullRequest' if($isPullRequestBuild) { + # Set of files that don't require build or test when changed + $skipFiles = @( + 'CHANGELOG.md', + 'README.md', + 'SUPPORT.md', + 'TROUBLESHOOTING.md', + 'CONTRIBUTING.md', + 'CODE_OF_CONDUCT.md', + 'SECURITY.md', + 'NOTICE.txt', + 'LICENSE' + ) + # If we're in a pull request, use the set of changed files to narrow down the set of paths to test. $changedFiles = Get-ChangedFiles # Assuming $changedFiles = [ @@ -223,6 +235,7 @@ function Get-PathsToTest { # For example, updating a markdown file in a service path will still trigger tests for that path. # Updating a file outside of the defined paths will be seen as a change to the core path. $changedPaths = @($changedFiles + | Where-Object { $skipFiles -notcontains (Split-Path $_ -Leaf) } | ForEach-Object { $_ -match $projectDirectoryPattern -and $normalizedPaths -contains $Matches[0] ? $Matches[0] : 'core/Microsoft.Mcp.Core' } | Sort-Object -Unique) From a425a423efef3432ed9d72ecf7d646027cc69333 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Thu, 6 Nov 2025 17:10:59 -0800 Subject: [PATCH 14/17] Set matrices content to empty if ther are no paths to test --- eng/pipelines/templates/common.yml | 52 ++++++++++++++---------------- eng/scripts/New-BuildInfo.ps1 | 19 ++++++----- 2 files changed, 36 insertions(+), 35 deletions(-) diff --git a/eng/pipelines/templates/common.yml b/eng/pipelines/templates/common.yml index 3ed5b94a7e..da6f8f15b5 100644 --- a/eng/pipelines/templates/common.yml +++ b/eng/pipelines/templates/common.yml @@ -68,35 +68,33 @@ extends: - ${{ each os in split('linux|windows|macOS', '|') }}: - - ${{ if ne(stageDependencies.Initialize.Initialize.outputs[format('CreateBuildInfo.{0}BuildMatrix', os)], '') }}: - - template: /eng/pipelines/templates/jobs/build.yml - parameters: - TestTimeoutInMinutes: 30 - ServerName: ${{ parameters.ServerName }} - PublishTarget: ${{ parameters.PublishTarget }} - OSName: ${{ os }} - Matrix: stageDependencies.Initialize.Initialize.outputs['CreateBuildInfo.${{ os }}BuildMatrix'] - MaxParallel: 4 + - template: /eng/pipelines/templates/jobs/build.yml + parameters: + TestTimeoutInMinutes: 30 + ServerName: ${{ parameters.ServerName }} + PublishTarget: ${{ parameters.PublishTarget }} + OSName: ${{ os }} + Matrix: stageDependencies.Initialize.Initialize.outputs['CreateBuildInfo.${{ os }}BuildMatrix'] + MaxParallel: 4 - ${{ if and(eq(variables['System.TeamProject'], 'internal'), eq(parameters.RunLiveTests, 'true')) }}: - - ${{ if ne(stageDependencies.Initialize.Initialize.outputs[CreateBuildInfo.liveTestMatrix], '') }}: - - stage: Test - displayName: 'Live test' - dependsOn: - - Initialize - pool: - name: $(LINUXPOOL) - image: $(LINUXVMIMAGE) - os: linux - variables: - - template: /eng/pipelines/templates/variables/image.yml - - template: /eng/pipelines/templates/variables/globals.yml - jobs: - - template: /eng/pipelines/templates/jobs/live-test.yml - parameters: - Matrix: stageDependencies.Initialize.Initialize.outputs['CreateBuildInfo.liveTestMatrix'] - MaxParallel: 10 - TimeoutInMinutes: 75 + - stage: Test + displayName: 'Live test' + dependsOn: + - Initialize + pool: + name: $(LINUXPOOL) + image: $(LINUXVMIMAGE) + os: linux + variables: + - template: /eng/pipelines/templates/variables/image.yml + - template: /eng/pipelines/templates/variables/globals.yml + jobs: + - template: /eng/pipelines/templates/jobs/live-test.yml + parameters: + Matrix: stageDependencies.Initialize.Initialize.outputs['CreateBuildInfo.liveTestMatrix'] + MaxParallel: 10 + TimeoutInMinutes: 75 - ${{ if ne(parameters.PublishTarget, 'none') }}: # We only sign if we're going to publish diff --git a/eng/scripts/New-BuildInfo.ps1 b/eng/scripts/New-BuildInfo.ps1 index 57735b67a5..ddb15e5901 100644 --- a/eng/scripts/New-BuildInfo.ps1 +++ b/eng/scripts/New-BuildInfo.ps1 @@ -608,14 +608,10 @@ Push-Location $RepoRoot try { $serverDetails = @(Get-ServerDetails) $pathsToTest = @(Get-PathsToTest) - $matrices = [ordered]@{} - - if ($pathsToTest.Count -gt 0) { - $matrices = Get-BuildMatrices $serverDetails - $matrices['liveTestMatrix'] = Get-TestMatrix $pathsToTest -TestType 'Live' - $matrices['serverMatrix'] = Get-ServerMatrix $serverDetails - } - + $matrices = Get-BuildMatrices $serverDetails + $matrices['liveTestMatrix'] = Get-TestMatrix $pathsToTest -TestType 'Live' + $matrices['serverMatrix'] = Get-ServerMatrix $serverDetails + # spellchecker: ignore SOURCEVERSION $branch = $isPipelineRun ? (CheckVariable 'BUILD_SOURCEBRANCH') : (git rev-parse --abbrev-ref HEAD) $commitSha = $isPipelineRun ? (CheckVariable 'BUILD_SOURCEVERSION') : (git rev-parse HEAD) @@ -638,6 +634,13 @@ try { $buildInfo | ConvertTo-Json -Depth 5 | Out-File -FilePath $OutputPath -Encoding utf8 -Force + # if path to test is empty, set all matrices to empty + if ($pathsToTest.Count -eq 0) { + foreach ($key in $matrices.Keys) { + $matrices[$key] = @{} + } + } + if ($isPipelineRun) { foreach($key in $matrices.Keys) { $matrixJson = $matrices[$key] | ConvertTo-Json -Compress From 748752ac244a83fa968f07ead8bb724a337dfffe Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Thu, 6 Nov 2025 18:04:32 -0800 Subject: [PATCH 15/17] Remove Set-SkipJobVariables script --- eng/pipelines/templates/common.yml | 1 - eng/pipelines/templates/jobs/initialize.yml | 8 --- eng/scripts/New-BuildInfo.ps1 | 2 +- eng/scripts/Set-SkipJobVariables.ps1 | 60 --------------------- 4 files changed, 1 insertion(+), 70 deletions(-) delete mode 100644 eng/scripts/Set-SkipJobVariables.ps1 diff --git a/eng/pipelines/templates/common.yml b/eng/pipelines/templates/common.yml index da6f8f15b5..c4892c5553 100644 --- a/eng/pipelines/templates/common.yml +++ b/eng/pipelines/templates/common.yml @@ -66,7 +66,6 @@ extends: jobs: - template: /eng/pipelines/templates/jobs/analyze.yml - - ${{ each os in split('linux|windows|macOS', '|') }}: - template: /eng/pipelines/templates/jobs/build.yml parameters: diff --git a/eng/pipelines/templates/jobs/initialize.yml b/eng/pipelines/templates/jobs/initialize.yml index 8ae5f10839..29f7f5c8d2 100644 --- a/eng/pipelines/templates/jobs/initialize.yml +++ b/eng/pipelines/templates/jobs/initialize.yml @@ -15,14 +15,6 @@ jobs: - checkout: self fetchDepth: 0 - #- task: PowerShell@2 - # displayName: "Set PR skip job variables" - # name: SetPRSkipJobVariables - # condition: eq(variables['Build.Reason'], 'PullRequest') - # inputs: - # pwsh: true - # filePath: $(Build.SourcesDirectory)/eng/scripts/Set-SkipJobVariables.ps1 - - task: UseDotNet@2 displayName: "Use .NET SDK from global.json" retryCountOnTaskFailure: 3 diff --git a/eng/scripts/New-BuildInfo.ps1 b/eng/scripts/New-BuildInfo.ps1 index ddb15e5901..75d57351cb 100644 --- a/eng/scripts/New-BuildInfo.ps1 +++ b/eng/scripts/New-BuildInfo.ps1 @@ -611,7 +611,7 @@ try { $matrices = Get-BuildMatrices $serverDetails $matrices['liveTestMatrix'] = Get-TestMatrix $pathsToTest -TestType 'Live' $matrices['serverMatrix'] = Get-ServerMatrix $serverDetails - + # spellchecker: ignore SOURCEVERSION $branch = $isPipelineRun ? (CheckVariable 'BUILD_SOURCEBRANCH') : (git rev-parse --abbrev-ref HEAD) $commitSha = $isPipelineRun ? (CheckVariable 'BUILD_SOURCEVERSION') : (git rev-parse HEAD) diff --git a/eng/scripts/Set-SkipJobVariables.ps1 b/eng/scripts/Set-SkipJobVariables.ps1 deleted file mode 100644 index fafd57ff8d..0000000000 --- a/eng/scripts/Set-SkipJobVariables.ps1 +++ /dev/null @@ -1,60 +0,0 @@ -. "$PSScriptRoot/../common/scripts/common.ps1" -$RepoRoot = $RepoRoot.Path.Replace('\', '/') - -# Set of files that don't require build or test when changed -$skipFiles = @( - 'CHANGELOG.md', - 'README.md', - 'SUPPORT.md', - 'TROUBLESHOOTING.md', - 'CONTRIBUTING.md', - 'CODE_OF_CONDUCT.md', - 'SECURITY.md', - 'NOTICE.txt', - 'LICENSE' -) - -# Set of directories that don't require build or test when changed -$skipDirectories = @( - '.github/', - 'eng/images/', - 'docs', - 'Resources' -) - -$skipBuildAndTest = $true - -$changedFilesScriptPath = "$RepoRoot/eng/common/scripts/get-changedfiles.ps1" -$changedFiles = & $changedFilesScriptPath -DiffFilterType '' - -if ($changedFiles) { - foreach ($file in $changedFiles) { - Write-Host "Checking file: $file" - $fileName = [System.IO.Path]::GetFileName($file) - $isSkipFile = $skipFiles -contains $fileName - - $isInSkipDirectory = $false - foreach ($dir in $skipDirectories) { - if ($file.StartsWith($dir, [System.StringComparison]::OrdinalIgnoreCase)) { - $isInSkipDirectory = $true - break - } - } - - Write-Host " -> File: $fileName, IsSkipFile: $isSkipFile, IsInSkipDir: $isInSkipDirectory" - if (-not $isSkipFile -and -not $isInSkipDirectory) { - $skipBuildAndTest = $false - Write-Host " -> File: $file requires build and test!" - return - } - } -} - -if ($skipBuildAndTest) { - Write-Host "##vso[task.setvariable variable=SkipBuildJob;isOutput=true]true" - Write-Host "##vso[task.setvariable variable=SkipLiveTestJob;isOutput=true]true" - Write-Host "SkipBuildJob set to: true" - Write-Host "SkipLiveTestJob set to: true" -} else { - Write-Host "This PR contains files that require build and/or test." -} \ No newline at end of file From 8c6a93c2f1148d23342410701a8fcb555adb1f8d Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Tue, 11 Nov 2025 13:41:53 -0800 Subject: [PATCH 16/17] update matrices for pullrequest builds --- eng/scripts/New-BuildInfo.ps1 | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/eng/scripts/New-BuildInfo.ps1 b/eng/scripts/New-BuildInfo.ps1 index 75d57351cb..b34937e1ec 100644 --- a/eng/scripts/New-BuildInfo.ps1 +++ b/eng/scripts/New-BuildInfo.ps1 @@ -16,6 +16,7 @@ param( . "$PSScriptRoot/helpers/PathHelpers.ps1" $RepoRoot = $RepoRoot.Path.Replace('\', '/') $isPipelineRun = $CI -or $env:TF_BUILD -eq 'true' +$isPullRequestBuild = $env:BUILD_REASON -eq 'PullRequest' $exitCode = 0 # We currently only want to build linux-x64 native @@ -205,8 +206,6 @@ function Get-PathsToTest { | ForEach-Object { $Matches[0] } | Sort-Object -Unique - $isPullRequestBuild = $env:BUILD_REASON -eq 'PullRequest' - if($isPullRequestBuild) { # Set of files that don't require build or test when changed $skipFiles = @( @@ -634,15 +633,12 @@ try { $buildInfo | ConvertTo-Json -Depth 5 | Out-File -FilePath $OutputPath -Encoding utf8 -Force - # if path to test is empty, set all matrices to empty - if ($pathsToTest.Count -eq 0) { - foreach ($key in $matrices.Keys) { - $matrices[$key] = @{} - } - } - if ($isPipelineRun) { foreach($key in $matrices.Keys) { + if ($isPullRequestBuild -and $pathsToTest.Count -eq 0) { + $matrices[$key] = @{} + } + $matrixJson = $matrices[$key] | ConvertTo-Json -Compress Write-Host "##vso[task.setvariable variable=${key};isOutput=true]$matrixJson" } From 8aff9401e9b0b81df5b41cf20aa65b3607b9ca22 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Tue, 11 Nov 2025 15:23:50 -0800 Subject: [PATCH 17/17] update buildInfo after matrices --- eng/scripts/New-BuildInfo.ps1 | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/eng/scripts/New-BuildInfo.ps1 b/eng/scripts/New-BuildInfo.ps1 index b34937e1ec..d6141cc3ad 100644 --- a/eng/scripts/New-BuildInfo.ps1 +++ b/eng/scripts/New-BuildInfo.ps1 @@ -615,6 +615,17 @@ try { $branch = $isPipelineRun ? (CheckVariable 'BUILD_SOURCEBRANCH') : (git rev-parse --abbrev-ref HEAD) $commitSha = $isPipelineRun ? (CheckVariable 'BUILD_SOURCEVERSION') : (git rev-parse HEAD) + if ($isPipelineRun) { + foreach($key in $matrices.Keys) { + if ($isPullRequestBuild -and $pathsToTest.Count -eq 0) { + $matrices[$key] = @{} + } + + $matrixJson = $matrices[$key] | ConvertTo-Json -Compress + Write-Host "##vso[task.setvariable variable=${key};isOutput=true]$matrixJson" + } + } + $buildInfo = [ordered]@{ buildId = $BuildId publishTarget = $PublishTarget @@ -632,17 +643,6 @@ try { New-Item -Path $parentDirectory -ItemType Directory -Force | Out-Null $buildInfo | ConvertTo-Json -Depth 5 | Out-File -FilePath $OutputPath -Encoding utf8 -Force - - if ($isPipelineRun) { - foreach($key in $matrices.Keys) { - if ($isPullRequestBuild -and $pathsToTest.Count -eq 0) { - $matrices[$key] = @{} - } - - $matrixJson = $matrices[$key] | ConvertTo-Json -Compress - Write-Host "##vso[task.setvariable variable=${key};isOutput=true]$matrixJson" - } - } } finally { Pop-Location