Skip to content

Commit a65934d

Browse files
committed
Add date on generation branch name
1 parent 15a526a commit a65934d

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

.azure-pipelines/PipelineSteps/BatchGeneration/create-branch.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ $body = @{
1919
Invoke-RestMethod -Uri "https://api.github.com/repos/$Owner/$Repo/git/refs" `
2020
-Method Post -Headers $headers -Body $body -ContentType "application/json"
2121

22-
Write-Host "Created branch '$NewBranch' from '$BBaseBranch'"
22+
Write-Host "Created branch '$NewBranch' from '$BaseBranch'"

.azure-pipelines/batch-generation.yml

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ variables:
2020
LinuxAgentPoolName: pool-ubuntu-2004
2121
MacOSAgentPoolName: 'Azure Pipelines'
2222
MacOSAgentPoolVMImage: macOS-latest
23-
GenerationBranch: batch-generation/branch-$(Build.BuildId)
2423

2524
trigger: none
2625

@@ -42,17 +41,20 @@ stages:
4241
- template: util/get-github-pat-steps.yml
4342

4443
- task: PowerShell@2
44+
name: checkout
4545
displayName: 'Create Batch Generation Branch'
4646
inputs:
4747
targetType: inline
4848
pwsh: true
4949
script: |
50-
$newBranch = "$(GenerationBranch)"
50+
$date = Get-Date -Format "yy-MM-dd"
51+
$generationBranch = "batch-generation/branch-$date-$(Build.BuildId)"
5152
$token = "$(GitHubToken)"
5253
5354
$createBranchPath = Join-Path "$(Build.SourcesDirectory)" '.azure-pipelines' 'PipelineSteps' 'BatchGeneration' 'create-branch.ps1'
5455
# TODO: (Bernard) Change BaseBranch to main after test
55-
& $createBranchPath -Owner 'Azure' -Repo 'azure-powershell' -BaseBranch 'bernard-pipeline-generation' -NewBranch $newBranch -Token $token
56+
& $createBranchPath -Owner 'Azure' -Repo 'azure-powershell' -BaseBranch 'bernard-pipeline-generation' -NewBranch $generationBranch -Token $token
57+
Write-Host "##vso[task.setvariable variable=GenerationBranch;isOutput=true]$generationBranch"
5658
5759
- task: PowerShell@2
5860
name: mtrx
@@ -77,6 +79,8 @@ stages:
7779
ne(dependencies.prepare.outputs['mtrx.generationTargets'], ''),
7880
ne(dependencies.prepare.outputs['mtrx.generationTargets'], '{}')
7981
)
82+
variables:
83+
GenerationBranch: $[dependencies.prepare.outputs['checkout.GenerationBranch']]
8084
timeoutInMinutes: ${{ variables.GenerateTimeoutInMinutes }}
8185
pool: ${{ variables.WindowsAgentPoolName }}
8286
strategy:
@@ -100,12 +104,11 @@ stages:
100104
targetType: inline
101105
pwsh: true
102106
script: |
103-
git fetch origin "${{ variables.GenerationBranch }}"
104-
git checkout "${{ variables.GenerationBranch }}"
107+
git fetch origin "$(GenerationBranch)"
108+
git checkout "$(GenerationBranch)"
105109
106110
$batchGenerateModulesPath = Join-Path "$(Build.SourcesDirectory)" '.azure-pipelines' 'PipelineSteps' 'BatchGeneration' 'batch-generate-modules.ps1'
107111
& $batchGenerateModulesPath -MatrixKey "$(MatrixKey)" -RepoRoot "$(Build.SourcesDirectory)" -CommitTitle "${{ parameters.CommitTitle }}"
108-
109112
workingDirectory: $(Build.SourcesDirectory)
110113

111114
- task: PublishPipelineArtifact@1
@@ -116,7 +119,10 @@ stages:
116119
condition: always()
117120

118121
- stage: Build
122+
dependsOn: Generate
119123
condition: always()
124+
variables:
125+
GenerationBranch: $[stageDependencies.Generate.prepare.outputs['checkout.GenerationBranch']]
120126
jobs:
121127
- job: filter
122128
displayName: 'Filter Changed Modules'
@@ -134,8 +140,8 @@ stages:
134140
targetType: inline
135141
pwsh: true
136142
script: |
137-
git fetch origin "${{ variables.GenerationBranch }}"
138-
git checkout "${{ variables.GenerationBranch }}"
143+
git fetch origin "$(GenerationBranch)"
144+
git checkout "$(GenerationBranch)"
139145
140146
- task: DownloadPipelineArtifact@2
141147
inputs:
@@ -156,7 +162,7 @@ stages:
156162
git config user.email "[email protected]"
157163
git config user.name "azure-powershell-bot"
158164
159-
Write-Host "Applying all .patch files to ${{ variables.GenerationBranch }}..."
165+
Write-Host "Applying all .patch files to "$(GenerationBranch)"..."
160166
$patchFiles = Get-ChildItem -Path "$env:PIPELINE_WORKSPACE" -Recurse -Filter *.patch
161167
162168
foreach ($patch in $patchFiles) {
@@ -165,8 +171,8 @@ stages:
165171
}
166172
167173
git add .
168-
git commit -m "Apply batch generation patches to ${{ variables.GenerationBranch }}"
169-
git push origin "${{ variables.GenerationBranch }}"
174+
git commit -m "Autorest Upgration - ${{ parameters.CommitTitle }}"
175+
git push origin "$(GenerationBranch)"
170176
171177
- task: PowerShell@2
172178
name: mtrx
@@ -229,8 +235,8 @@ stages:
229235
targetType: inline
230236
pwsh: true
231237
script: |
232-
git fetch origin "${{ variables.GenerationBranch }}"
233-
git checkout "${{ variables.GenerationBranch }}"
238+
git fetch origin "$(GenerationBranch)"
239+
git checkout "$(GenerationBranch)"
234240
235241
$buildModulesPath = Join-Path "$(Build.SourcesDirectory)" '.azure-pipelines' 'PipelineSteps' 'BatchGeneration' 'build-modules.ps1'
236242
& $buildModulesPath -MatrixKey "$(MatrixKey)" -RepoRoot "$(Build.SourcesDirectory)"

0 commit comments

Comments
 (0)