|
4 | 4 | [string]$githubOptionsAccountName, |
5 | 5 | [string]$githubOptionsAccountEmail, |
6 | 6 | [string]$vstsTokenBase64, |
7 | | - [bool]$needRunReleaseMdoc |
| 7 | + [string]$step, |
| 8 | + [string]$commit1 |
8 | 9 | ) |
9 | 10 |
|
10 | 11 | function Git-Init([string]$githubAccountName, [string]$githubAccountEmail) |
@@ -41,6 +42,11 @@ function Git-Push([string]$rootPath, [string] $token, [string] $commitMessage, [ |
41 | 42 | { |
42 | 43 | & git add --all |
43 | 44 | & git commit -m $commitMessage |
| 45 | + |
| 46 | + & git config pull.rebase false |
| 47 | + Write-Host 'git -c http.extraHeader="Authorization: Basic '$token'" pull' |
| 48 | + & git -c http.extraHeader="Authorization: Basic $token" pull |
| 49 | + |
44 | 50 | & git -c http.extraHeader="Authorization: Basic $token" push --set-upstream origin $branch --force-with-lease |
45 | 51 | } |
46 | 52 | } |
@@ -107,7 +113,6 @@ function Run($source_repo,$target_repo,$origin_target_repo) |
107 | 113 | Write-Host "origin target repo folder is null or empty!" |
108 | 114 | } |
109 | 115 |
|
110 | | - |
111 | 116 | $sourceRepoUrl = $source_repo.url |
112 | 117 | $sourceRepoBranch = $source_repo.branch |
113 | 118 | $sourceFolder = $source_repo.folder |
@@ -138,69 +143,67 @@ function Run($source_repo,$target_repo,$origin_target_repo) |
138 | 143 |
|
139 | 144 | Write-Host "==================== Clone target repo: $targetRepoUrl" |
140 | 145 | Git-Clone $targetRepoUrl $targetRepoPath $githubTokenBase64 $targetRepoBranch |
| 146 | + |
141 | 147 | if (Test-Path $xmlPath) |
142 | 148 | { |
143 | 149 | Write-Host "Delete files under path: $xmlPath" |
144 | 150 | Remove-Item -Recurse -Force $xmlPath\* |
145 | 151 | Write-Host "Delete files done." |
146 | 152 | } |
147 | 153 | Copy-Item "$originRepoXmlPath\*" -Destination "$xmlPath\" -Recurse -Force -Container |
148 | | - |
149 | | - if ($needRunReleaseMdoc -eq $true) |
150 | | - { |
| 154 | + |
| 155 | + # This part(if) run in Job_1 |
| 156 | + if($step -eq "1"){ |
151 | 157 | Write-Host "==================== Run Mdoc(release version) tool to generated xml files." |
152 | 158 | Run-Mdoc $releaseMdocPath $frameworksPath $xmlPath |
153 | 159 | if ($lastexitcode -ne 0) |
154 | 160 | { |
155 | 161 | exit $lastexitcode |
156 | 162 | } |
157 | | - } |
158 | | - |
159 | | - Write-Host "==================== First to commit xml files" |
160 | | - $message = "CI Update 1 with build number " + $env:BUILD_BUILDNUMBER |
161 | | - Git-Push $targetRepoPath $githubTokenBase64 $message $targetRepoBranch |
162 | | - $commitid1 = & git rev-parse HEAD |
163 | | - Write-Host "Commit Id1: $commitid1" |
164 | | - Pop-Location |
165 | | - if (Test-Path $xmlPath) |
166 | | - { |
167 | | - Write-Host "Delete files under path: $xmlPath" |
168 | | - Remove-Item -Recurse -Force $xmlPath\* |
169 | | - Write-Host "Delete files done." |
170 | | - } |
171 | | - Copy-Item "$originRepoXmlPath\*" -Destination "$xmlPath\" -Recurse -Force -Container |
172 | | - |
173 | | - Write-Host "==================== Run Mdoc(pr version) tool to generated xml files." |
174 | | - Run-Mdoc $prMdocPath $frameworksPath $xmlPath |
175 | | - if ($lastexitcode -ne 0) |
176 | | - { |
177 | | - exit $lastexitcode |
178 | | - } |
179 | | - |
180 | | - Write-Host "==================== Sencond to commit xml files" |
181 | | - $message = "CI Update 2 with build number " + $env:BUILD_BUILDNUMBER |
182 | | - Git-Push $targetRepoPath $githubTokenBase64 $message $targetRepoBranch |
183 | | - $commitid2 = & git rev-parse HEAD |
184 | | - Write-Host "Commit Id2: $commitid2" |
185 | | - Pop-Location |
| 163 | + |
| 164 | + Write-Host "==================== First to commit xml files" |
| 165 | + $message = "CI Update 1 with build number " + $env:BUILD_BUILDNUMBER |
| 166 | + Git-Push $targetRepoPath $githubTokenBase64 $message $targetRepoBranch |
| 167 | + $commitid1 = & git rev-parse HEAD |
| 168 | + Write-Host "Commit Id1: $commitid1" |
| 169 | + Pop-Location |
| 170 | + |
| 171 | + Write-Host "##vso[task.setvariable variable=commit1;isOutput=true]$commitid1" |
| 172 | + } else { # This part(else) run in Job_2 |
186 | 173 |
|
187 | | - Write-Host "==================== Compare two version xml files." |
188 | | - $shortCommitId1 = $commitid1.Substring(0, 7) |
189 | | - $shortCommitId2 = $commitid2.Substring(0, 7) |
190 | | - if($targetRepoUrl.EndsWith(".git")) |
191 | | - { |
192 | | - $compareUrl = $targetRepoUrl.Substring(0, $ymlRepoUrl.Length - 4) |
193 | | - } |
194 | | - else |
195 | | - { |
196 | | - $compareUrl = $targetRepoUrl |
| 174 | + Write-Host "==================== Run Mdoc(pr version) tool to generated xml files." |
| 175 | + Run-Mdoc $prMdocPath $frameworksPath $xmlPath |
| 176 | + if ($lastexitcode -ne 0) |
| 177 | + { |
| 178 | + exit $lastexitcode |
| 179 | + } |
| 180 | + |
| 181 | + Write-Host "==================== Sencond to commit xml files" |
| 182 | + $message = "CI Update 2 with build number " + $env:BUILD_BUILDNUMBER |
| 183 | + Git-Push $targetRepoPath $githubTokenBase64 $message $targetRepoBranch |
| 184 | + $commitid2 = & git rev-parse HEAD |
| 185 | + Write-Host "Commit Id2: $commitid2" |
| 186 | + Pop-Location |
| 187 | + |
| 188 | + Write-Host "==================== Compare two version xml files." |
| 189 | + $commitid1 = $commit1 # commit1 from job_1 |
| 190 | + $shortCommitId1 = $commitid1.Substring(0, 7) |
| 191 | + $shortCommitId2 = $commitid2.Substring(0, 7) |
| 192 | + if($targetRepoUrl.EndsWith(".git")) |
| 193 | + { |
| 194 | + $compareUrl = $targetRepoUrl.Substring(0, $ymlRepoUrl.Length - 4) |
| 195 | + } |
| 196 | + else |
| 197 | + { |
| 198 | + $compareUrl = $targetRepoUrl |
| 199 | + } |
| 200 | + |
| 201 | + $compareUrl = $compareUrl + "/compare/" |
| 202 | + $compareUrl = $compareUrl + "$shortCommitId1...$shortCommitId2/" |
| 203 | + |
| 204 | + Write-Host ("##vso[task.setvariable variable=CompareUrl;]$compareUrl") |
| 205 | + Write-Host "Compare Url: $compareUrl" |
197 | 206 | } |
198 | | - |
199 | | - $compareUrl = $compareUrl + "/compare/" |
200 | | - $compareUrl = $compareUrl + "$shortCommitId1...$shortCommitId2/" |
201 | | - |
202 | | - Write-Host ("##vso[task.setvariable variable=CompareUrl;]$compareUrl") |
203 | | - Write-Host "Compare Url: $compareUrl" |
204 | 207 | } |
205 | 208 |
|
206 | 209 | $params = $paramsJson | ConvertFrom-Json |
|
0 commit comments