@@ -23,8 +23,16 @@ stages:
23
23
24
24
- powershell : |
25
25
$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
+ }
28
36
displayName: "Determine the number of the week in the sprint and sprint number"
29
37
30
38
- powershell : |
@@ -34,16 +42,16 @@ stages:
34
42
git merge origin/master
35
43
git push origin Localization
36
44
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'))
38
46
39
47
- 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'))
41
49
inputs :
42
50
locProj : ' Localize/LocProject.json'
43
51
outDir : ' $(Build.ArtifactStagingDirectory)'
44
52
packageSourceAuth : ' patAuth'
45
53
patVariable : ' $(OneLocBuildPAT)'
46
- isCreatePrSelected : true
54
+ isCreatePrSelected : $(shouldCreatePR)
47
55
repoType : ' gitHub'
48
56
prSourceBranchPrefix : ' Localize'
49
57
gitHubPatVariable : ' $(GitHubPAT)'
@@ -52,7 +60,7 @@ stages:
52
60
SYSTEM_ACCESSTOKEN : $(System.AccessToken)
53
61
54
62
- 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'))
56
64
displayName : ' Publish an artifact'
57
65
58
66
- powershell : |
@@ -68,7 +76,7 @@ stages:
68
76
git commit -m "Removing Localize folder"
69
77
git push origin $updateBranch
70
78
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')))
72
80
73
81
- task : PowerShell@2
74
82
inputs :
@@ -78,7 +86,7 @@ stages:
78
86
env :
79
87
GH_TOKEN : ' $(GitHubPAT)'
80
88
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')))
82
90
83
91
- powershell : |
84
92
$message="Created tool-lib localization update PR. Someone please approve/merge it. :please-puss-in-boots: $env:PR_LINK"
@@ -88,7 +96,7 @@ stages:
88
96
89
97
Invoke-RestMethod -Uri $(slackUri) -Method Post -Body $body -ContentType 'application/json'
90
98
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'))
92
100
93
101
- powershell : |
94
102
$buildUrl = "$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&_a=summary"
@@ -99,4 +107,4 @@ stages:
99
107
100
108
Invoke-RestMethod -Uri $(slackUri) -Method Post -Body $body -ContentType 'application/json'
101
109
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