Skip to content

Commit 251bf0d

Browse files
authored
PMC parse state correctly from update command's response (PowerShell#24850)
* Parse Json before accessing state property for PMC * fix typo
1 parent 1318d6a commit 251bf0d

File tree

1 file changed

+13
-4
lines changed
  • .pipelines/EV2Specs/ServiceGroupRoot/Shell/Run

1 file changed

+13
-4
lines changed

.pipelines/EV2Specs/ServiceGroupRoot/Shell/Run/Run.ps1

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,9 @@ function Publish-PackageToPMC() {
226226
continue
227227
}
228228

229-
$state = $rawUpdateResponse.state
230-
if ($state -ne 'Completed') {
229+
$state = ($rawUpdateResponse | ConvertFrom-Json).state
230+
Write-Verbose -Verbose "update response state: $state"
231+
if ($state -ne 'completed') {
231232
$errorMessage.Add("Publishing package $($finalPackage.PackageName) to $pkgRepo failed: $rawUpdateResponse")
232233
continue
233234
}
@@ -242,11 +243,19 @@ function Publish-PackageToPMC() {
242243

243244
# At this point, the changes are staged and will eventually be publish.
244245
# Running publish, causes them to go live "immediately"
246+
$rawPublishResponse = $null
245247
try {
246-
pmc --config $ConfigPath repo publish $pkgRepo
248+
$rawPublishResponse = pmc --config $ConfigPath repo publish $pkgRepo
247249
}
248250
catch {
249-
$errorMessage.Add("Running final publish for package $($finalPackage.PackageName) to $pkgRepo failed. See errors above for details.")
251+
$errorMessage.Add("Invoking final publish for package $($finalPackage.PackageName) to $pkgRepo failed. See errors above for details.")
252+
continue
253+
}
254+
255+
$publishState = ($rawPublishResponse | ConvertFrom-Json).state
256+
Write-Verbose -Verbose "publish response state: $publishState"
257+
if ($publishState -ne 'completed') {
258+
$errorMessage.Add("Final publishing of package $($finalPackage.PackageName) to $pkgRepo failed: $rawPublishResponse")
250259
continue
251260
}
252261
} else {

0 commit comments

Comments
 (0)