Skip to content

Commit 2f4bd9b

Browse files
wtgodbedougbu
andauthored
Allow explicit manual runs of mirror pipeline (#41736)
* Allow explicit manual runs of mirror pipeline * Fixup * Fixup 2 * Try different approach * Update .azure/pipelines/azure-pipelines-mirror-within-azdo.yml * Update .azure/pipelines/azure-pipelines-mirror-within-azdo.yml Co-authored-by: Doug Bunting <[email protected]> Co-authored-by: Doug Bunting <[email protected]>
1 parent bf50999 commit 2f4bd9b

File tree

1 file changed

+53
-46
lines changed

1 file changed

+53
-46
lines changed

.azure/pipelines/azure-pipelines-mirror-within-azdo.yml

Lines changed: 53 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,58 +4,65 @@ trigger:
44
branches:
55
include:
66
- internal/release/6.0
7+
8+
parameters:
9+
# Run the pipeline manually (usually disallowed)
10+
- name: manualRun
11+
default: false
12+
displayName: Are you sure you want to run this pipeline manually?
13+
type: boolean
714

815
variables:
916
- group: Mirror-Credentials
1017

1118
# Merges code from one AzDO branch into another
1219
jobs:
13-
- template: /eng/common/templates/jobs/jobs.yml
14-
parameters:
15-
enableTelemetry: true
16-
helixRepo: dotnet/arcade
17-
jobs:
18-
- job: Merge_Azure_DevOps_Branches
19-
enableSBOM: false
20-
condition: and(contains(variables['Build.SourceBranch'], 'internal'), eq(variables['Build.Reason'], 'BatchedCI'))
21-
pool:
22-
name: NetCore1ESPool-Internal
23-
demands: ImageOverride -equals Build.Server.Amd64.VS2019
24-
variables:
25-
- name: WorkingDirectoryName
26-
value: repo-dir
27-
- name: AzdoRepo
28-
value: dotnet-aspnetcore
29-
- name: TargetBranchName
30-
value: $(Build.SourceBranch)-nonstable
31-
- name: BranchToMirror
32-
value: $(Build.SourceBranch)
33-
steps:
34-
- script: |
35-
git clone https://dn-bot:$(dn-bot-dnceng-build-rw-code-rw)@dev.azure.com/dnceng/internal/_git/$(AzdoRepo) $(WorkingDirectoryName) --recursive --no-tags --branch $(TargetBranchName)
36-
displayName: Clone AzDO repo
37-
- script: |
38-
git -c user.email="[email protected]" -c user.name="dotnet-bot" merge origin/$(BranchToMirror) -m "Merge in '$(BranchToMirror)' changes"
39-
displayName: Merge head branch to target branch
40-
workingDirectory: $(WorkingDirectoryName)
41-
- script: |
42-
git push origin $(TargetBranchName)
43-
displayName: Push changes to Azure DevOps repo
44-
workingDirectory: $(WorkingDirectoryName)
45-
46-
- task: PowerShell@1
47-
displayName: Broadcast target, branch, commit in metadata
48-
continueOnError: true
49-
condition: always()
50-
inputs:
51-
scriptType: inlineScript
52-
arguments: '$(BranchToMirror)'
20+
- ${{ if and(contains(variables['Build.SourceBranch'], 'internal'), or(eq(variables['Build.Reason'], 'BatchedCI'), eq(parameters.manualRun, 'true'))) }}:
21+
- template: /eng/common/templates/jobs/jobs.yml
22+
parameters:
23+
enableTelemetry: true
24+
helixRepo: dotnet/aspnetcore
25+
jobs:
26+
- job: Merge_Azure_DevOps_Branches
27+
enableSBOM: false
28+
pool:
29+
name: NetCore1ESPool-Internal
30+
demands: ImageOverride -equals Build.Server.Amd64.VS2019
31+
variables:
32+
- name: WorkingDirectoryName
33+
value: repo-dir
34+
- name: AzdoRepo
35+
value: dotnet-aspnetcore
36+
- name: TargetBranchName
37+
value: $(Build.SourceBranch)-nonstable
38+
- name: BranchToMirror
39+
value: $(Build.SourceBranch)
40+
steps:
41+
- script: |
42+
git clone https://dn-bot:$(dn-bot-dnceng-build-rw-code-rw)@dev.azure.com/dnceng/internal/_git/$(AzdoRepo) $(WorkingDirectoryName) --recursive --no-tags --branch $(TargetBranchName)
43+
displayName: Clone AzDO repo
44+
- script: |
45+
git -c user.email="[email protected]" -c user.name="dotnet-bot" merge origin/$(BranchToMirror) -m "Merge in '$(BranchToMirror)' changes"
46+
displayName: Merge head branch to target branch
47+
workingDirectory: $(WorkingDirectoryName)
48+
- script: |
49+
git push origin $(TargetBranchName)
50+
displayName: Push changes to Azure DevOps repo
5351
workingDirectory: $(WorkingDirectoryName)
54-
inlineScript: |
55-
param([string]$branch)
5652
57-
$commit = (git rev-parse HEAD).Substring(0, 7)
58-
$target = "$branch".Replace('/', ' ')
53+
- task: PowerShell@1
54+
displayName: Broadcast target, branch, commit in metadata
55+
continueOnError: true
56+
condition: always()
57+
inputs:
58+
scriptType: inlineScript
59+
arguments: '$(BranchToMirror)'
60+
workingDirectory: $(WorkingDirectoryName)
61+
inlineScript: |
62+
param([string]$branch)
63+
64+
$commit = (git rev-parse HEAD).Substring(0, 7)
65+
$target = "$branch".Replace('/', ' ')
5966
60-
Write-Host "##vso[build.updatebuildnumber]$target $commit"
61-
Write-Host "##vso[build.addbuildtag]$target"
67+
Write-Host "##vso[build.updatebuildnumber]$target $commit"
68+
Write-Host "##vso[build.addbuildtag]$target"

0 commit comments

Comments
 (0)