From a997cb9d931e1c5c03b1288ebe4756e06838023d Mon Sep 17 00:00:00 2001 From: Andrei Grigorev Date: Wed, 3 Jul 2024 16:29:04 -0700 Subject: [PATCH 1/4] Explicit invokation of target pipeline. --- .pipelines/Release-trigger.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.pipelines/Release-trigger.yml b/.pipelines/Release-trigger.yml index b322af8bab..ad36e5c84f 100644 --- a/.pipelines/Release-trigger.yml +++ b/.pipelines/Release-trigger.yml @@ -16,4 +16,15 @@ pool: vmImage: 'windows-latest' steps: -- powershell: Write-Host "Dummy task" +- powershell: |- + $body = @{ + "templateParameters": + { + "NuGetGallerySubmoduleBranch": "$(Build.SourceBranchName)" + } + } + $headers = @{ "Authorization" = "Bearer $env:ACCESS_TOKEN" }; + $url = "$(System.CollectionUri)$(System.TeamProject)/_apis/pipelines/21120/runs?api-version=7.0" + Invoke-RestMethod -Uri $url -Method POST -Headers $headers -Body ($body | ConvertTo-Json) -ContentType "application/json" + env: + ACCESS_TOKEN: $(System.AccessToken) From 70037f3bcd062b2a86fae8787c5087c90fd018f4 Mon Sep 17 00:00:00 2001 From: Andrei Grigorev Date: Wed, 3 Jul 2024 16:36:34 -0700 Subject: [PATCH 2/4] Syntax fixes. --- .pipelines/Release-trigger.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.pipelines/Release-trigger.yml b/.pipelines/Release-trigger.yml index ad36e5c84f..81294c0dd7 100644 --- a/.pipelines/Release-trigger.yml +++ b/.pipelines/Release-trigger.yml @@ -18,9 +18,8 @@ pool: steps: - powershell: |- $body = @{ - "templateParameters": - { - "NuGetGallerySubmoduleBranch": "$(Build.SourceBranchName)" + "templateParameters" = @{ + "NuGetGallerySubmoduleBranch" = "$(Build.SourceBranchName)" } } $headers = @{ "Authorization" = "Bearer $env:ACCESS_TOKEN" }; From cf66d0a78d3f1e8f208d76fd260e7920aa3ac0a9 Mon Sep 17 00:00:00 2001 From: Andrei Grigorev Date: Wed, 3 Jul 2024 17:00:47 -0700 Subject: [PATCH 3/4] More pipelines to trigger --- .pipelines/Release-trigger.yml | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/.pipelines/Release-trigger.yml b/.pipelines/Release-trigger.yml index 81294c0dd7..5dfe3755aa 100644 --- a/.pipelines/Release-trigger.yml +++ b/.pipelines/Release-trigger.yml @@ -8,22 +8,32 @@ trigger: pr: none +parameters: +- name: TargetPipelines + type: object + default: + - id: 21120 + paramName: NuGetGallerySubmoduleBranch + - id: 21280 + paramName: NuGetGalleryBranch + variables: - name: NugetMultifeedWarnLevel value: none - + pool: vmImage: 'windows-latest' steps: -- powershell: |- - $body = @{ - "templateParameters" = @{ - "NuGetGallerySubmoduleBranch" = "$(Build.SourceBranchName)" +- ${{ each pipeline in parameters.TargetPipelines }}: + - powershell: |- + $body = @{ + "templateParameters" = @{ + "$(pipeline.paramName)" = "$(Build.SourceBranchName)" + } } - } - $headers = @{ "Authorization" = "Bearer $env:ACCESS_TOKEN" }; - $url = "$(System.CollectionUri)$(System.TeamProject)/_apis/pipelines/21120/runs?api-version=7.0" - Invoke-RestMethod -Uri $url -Method POST -Headers $headers -Body ($body | ConvertTo-Json) -ContentType "application/json" - env: - ACCESS_TOKEN: $(System.AccessToken) + $headers = @{ "Authorization" = "Bearer $env:ACCESS_TOKEN" }; + $url = "$(System.CollectionUri)$(System.TeamProject)/_apis/pipelines/$(pipeline.id)/runs?api-version=7.0" + Invoke-RestMethod -Uri $url -Method POST -Headers $headers -Body ($body | ConvertTo-Json) -ContentType "application/json" + env: + ACCESS_TOKEN: $(System.AccessToken) From 523a849b8f1ab7057ddfd3365967a6abfa4b10f5 Mon Sep 17 00:00:00 2001 From: Andrei Grigorev Date: Wed, 3 Jul 2024 17:04:34 -0700 Subject: [PATCH 4/4] Syntax --- .pipelines/Release-trigger.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pipelines/Release-trigger.yml b/.pipelines/Release-trigger.yml index 5dfe3755aa..629def5be1 100644 --- a/.pipelines/Release-trigger.yml +++ b/.pipelines/Release-trigger.yml @@ -29,11 +29,11 @@ steps: - powershell: |- $body = @{ "templateParameters" = @{ - "$(pipeline.paramName)" = "$(Build.SourceBranchName)" + "${{ pipeline.paramName }}" = "$(Build.SourceBranchName)" } } $headers = @{ "Authorization" = "Bearer $env:ACCESS_TOKEN" }; - $url = "$(System.CollectionUri)$(System.TeamProject)/_apis/pipelines/$(pipeline.id)/runs?api-version=7.0" + $url = "$(System.CollectionUri)$(System.TeamProject)/_apis/pipelines/${{ pipeline.id }}/runs?api-version=7.0" Invoke-RestMethod -Uri $url -Method POST -Headers $headers -Body ($body | ConvertTo-Json) -ContentType "application/json" env: ACCESS_TOKEN: $(System.AccessToken)