Skip to content

Commit f6109aa

Browse files
authored
Backport branch mirror pipeline (#41760)
1 parent 78f64d8 commit f6109aa

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Configure which branches trigger builds
2+
trigger:
3+
batch: true
4+
branches:
5+
include:
6+
- 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
14+
15+
variables:
16+
- group: Mirror-Credentials
17+
18+
# Merges code from one AzDO branch into another
19+
jobs:
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
51+
workingDirectory: $(WorkingDirectoryName)
52+
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('/', ' ')
66+
67+
Write-Host "##vso[build.updatebuildnumber]$target $commit"
68+
Write-Host "##vso[build.addbuildtag]$target"

0 commit comments

Comments
 (0)