Skip to content

Commit f81410c

Browse files
authored
Create PR in OneLocBuild task only on third week of sprint (#110)
* Added additional variable for OneLoc build * Update pipeline * Use shouldCreatePR variable * Changed variables that is used for pipeline execution * Change condition * Fixed condition * Reverted sprint num * Revert missed value * Change conditions * Add option to disable PR creation
1 parent f71e11b commit f81410c

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

Localize/localize-pipeline.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,16 @@ stages:
2323

2424
- powershell: |
2525
$sprintInfo = Invoke-WebRequest https://whatsprintis.it -Headers @{"Accept"= "application/json"} | ConvertFrom-Json
26-
Write-Host "##vso[task.setvariable variable=week]$($sprintInfo.week)"
27-
Write-Host "##vso[task.setvariable variable=sprint]$($sprintInfo.sprint)"
26+
if (($env:PR_CREATION_ENABLED -eq 'True') -and (($sprintInfo.week -eq 3) -or ($env:BUILD_REASON -eq 'Manual')))
27+
{
28+
Write-Host "shouldCreatePR was set to true"
29+
Write-Host "##vso[task.setvariable variable=shouldCreatePR]$($true)"
30+
}
31+
else
32+
{
33+
Write-Host "shouldCreatePR was set to false"
34+
Write-Host "##vso[task.setvariable variable=shouldCreatePR]$($false)"
35+
}
2836
displayName: "Determine the number of the week in the sprint and sprint number"
2937
3038
- powershell: |
@@ -34,16 +42,16 @@ stages:
3442
git merge origin/master
3543
git push origin Localization
3644
displayName: "Sync with master branch"
37-
condition: and(succeeded(), or(and(eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule')), eq(variables['build.reason'], 'Manual')))
45+
condition: and(succeeded(), in(variables['build.reason'], 'Schedule', 'Manual'))
3846
3947
- task: OneLocBuild@2
40-
condition: and(succeeded(), or(and(eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule')), eq(variables['build.reason'], 'Manual')))
48+
condition: and(succeeded(), in(variables['build.reason'], 'Schedule', 'Manual'))
4149
inputs:
4250
locProj: 'Localize/LocProject.json'
4351
outDir: '$(Build.ArtifactStagingDirectory)'
4452
packageSourceAuth: 'patAuth'
4553
patVariable: '$(OneLocBuildPAT)'
46-
isCreatePrSelected: true
54+
isCreatePrSelected: $(shouldCreatePR)
4755
repoType: 'gitHub'
4856
prSourceBranchPrefix: 'Localize'
4957
gitHubPatVariable: '$(GitHubPAT)'
@@ -52,7 +60,7 @@ stages:
5260
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
5361

5462
- task: PublishBuildArtifacts@1
55-
condition: and(succeeded(), or(and(eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule')), eq(variables['build.reason'], 'Manual')))
63+
condition: and(succeeded(), in(variables['build.reason'], 'Schedule', 'Manual'))
5664
displayName: 'Publish an artifact'
5765

5866
- powershell: |
@@ -68,7 +76,7 @@ stages:
6876
git commit -m "Removing Localize folder"
6977
git push origin $updateBranch
7078
displayName: Create and push localization update branch
71-
condition: and(succeeded(), or(and(eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule')), eq(variables['build.reason'], 'Manual')))
79+
condition: and(succeeded(), or(and(eq(variables['SHOULDCREATEPR'], 'True'), eq(variables['build.reason'], 'Schedule')), eq(variables['build.reason'], 'Manual')))
7280
7381
- task: PowerShell@2
7482
inputs:
@@ -78,7 +86,7 @@ stages:
7886
env:
7987
GH_TOKEN: '$(GitHubPAT)'
8088
displayName: Open a PR
81-
condition: and(succeeded(), or(and(eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule')), eq(variables['build.reason'], 'Manual')))
89+
condition: and(succeeded(), or(and(eq(variables['SHOULDCREATEPR'], 'True'), eq(variables['build.reason'], 'Schedule')), eq(variables['build.reason'], 'Manual')))
8290

8391
- powershell: |
8492
$message="Created tool-lib localization update PR. Someone please approve/merge it. :please-puss-in-boots: $env:PR_LINK"
@@ -88,7 +96,7 @@ stages:
8896
8997
Invoke-RestMethod -Uri $(slackUri) -Method Post -Body $body -ContentType 'application/json'
9098
displayName: 'Send Slack notification about PR opened'
91-
condition: and(failed(), eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule'))
99+
condition: and(succeeded(), eq(variables['SHOULDCREATEPR'], 'True'), eq(variables['build.reason'], 'Schedule'))
92100
93101
- powershell: |
94102
$buildUrl = "$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&_a=summary"
@@ -99,4 +107,4 @@ stages:
99107
100108
Invoke-RestMethod -Uri $(slackUri) -Method Post -Body $body -ContentType 'application/json'
101109
displayName: 'Send Slack notification about error'
102-
condition: and(failed(), eq(variables['WEEK'], '3'), eq(variables['build.reason'], 'Schedule'))
110+
condition: and(failed(), eq(variables['SHOULDCREATEPR'], 'True'), eq(variables['build.reason'], 'Schedule'))

0 commit comments

Comments
 (0)