File tree 1 file changed +38
-3
lines changed
1 file changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -42,10 +42,45 @@ jobs:
42
42
git reset --hard origin/$(BranchToMirror)
43
43
displayName: Hard reset local branch to GitHub branch
44
44
workingDirectory: $(WorkingDirectoryName)
45
- - script : |
46
- git push azdo-mirror $(BranchToMirror) $(ExtraPushArgs)
45
+ - task : PowerShell@2
47
46
displayName : Push changes to Azure DevOps repo
48
- workingDirectory: $(WorkingDirectoryName)
47
+ inputs :
48
+ targetType : inline
49
+ workingDirectory : $(WorkingDirectoryName)
50
+ script : |
51
+ git push azdo-mirror $(BranchToMirror) $(ExtraPushArgs)
52
+
53
+ if ($LASTEXITCODE -EQ 0) {
54
+ Write-Host "Push was successful"
55
+ exit
56
+ }
57
+
58
+ git fetch azdo-mirror
59
+ git fetch origin
60
+ $commits = (git --no-pager rev-list origin/$(BranchToMirror)..azdo-mirror/$(BranchToMirror) | Measure-Object -line).Lines
61
+ if ($commits -NE 0) {
62
+ Write-Host "##vso[task.LogIssue type=error;]Mirror repository $(AzDORepoName) has unexpected commits"
63
+ git --no-pager log origin/$(BranchToMirror)..azdo-mirror/$(BranchToMirror)
64
+ exit 1
65
+ }
66
+
67
+ Write-Host "##vso[task.LogIssue type=warning;]Push failed for unknown reason"
68
+
69
+ $retryattempt=0
70
+ while ($retryattempt -LT 3) {
71
+ $retryattempt+=1
72
+ Write-Host "Retry attempt $retryattempt of 3 in 5 seconds..."
73
+ Start-Sleep -Seconds 5
74
+
75
+ git push azdo-mirror $(BranchToMirror) $(ExtraPushArgs)
76
+ if ($LASTEXITCODE -EQ 0) {
77
+ Write-Host "Push successful"
78
+ exit
79
+ }
80
+ }
81
+
82
+ Write-Host "##vso[task.LogIssue type=error;]git failed to push to Azure DevOps mirror"
83
+ exit 1
49
84
50
85
- task : PowerShell@1
51
86
displayName : Broadcast target, branch, commit in metadata
You can’t perform that action at this time.
0 commit comments