-
Notifications
You must be signed in to change notification settings - Fork 8.3k
[release/v7.6] Fix buildinfo.json uploading for preview, LTS, and stable releases #26715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,9 @@ jobs: | |
| $dateTime = [datetime]::new($dateTime.Ticks - ($dateTime.Ticks % [timespan]::TicksPerSecond), $dateTime.Kind) | ||
|
|
||
| $metadata = Get-Content -LiteralPath "$toolsDirectory/metadata.json" -ErrorAction Stop | ConvertFrom-Json | ||
| $stableReleaseTag = $metadata.StableReleaseTag -Replace 'v','' | ||
|
|
||
| $currentReleaseTag = $buildInfo.ReleaseTag -Replace 'v','' | ||
| $stableRelease = $metadata.StableRelease.PublishToChannels | ||
| $ltsRelease = $metadata.LTSRelease.PublishToChannels | ||
|
|
||
|
|
@@ -65,40 +68,44 @@ jobs: | |
|
|
||
| $buildInfo = $buildInfoJsonContent | ConvertFrom-Json | ||
| $buildInfo.ReleaseDate = $dateTime | ||
| $currentReleaseTag = $buildInfo.ReleaseTag -Replace 'v','' | ||
|
|
||
| $targetFile = "$ENV:PIPELINE_WORKSPACE/$fileName" | ||
| ConvertTo-Json -InputObject $buildInfo | Out-File $targetFile -Encoding ascii | ||
|
|
||
| if ($stableRelease -or $fileName -eq "preview.json") { | ||
| Set-BuildVariable -Name CopyMainBuildInfo -Value YES | ||
| if ($fileName -eq "preview.json") { | ||
| Set-BuildVariable -Name UploadPreview -Value YES | ||
| } else { | ||
| Set-BuildVariable -Name CopyMainBuildInfo -Value NO | ||
| Set-BuildVariable -Name UploadPreview -Value NO | ||
| } | ||
|
|
||
| Set-BuildVariable -Name BuildInfoJsonFile -Value $targetFile | ||
|
|
||
| ## Create 'lts.json' if it's the latest stable and also a LTS release. | ||
| Set-BuildVariable -Name PreviewBuildInfoFile -Value $targetFile | ||
|
||
|
|
||
| ## Create 'lts.json' if marked as a LTS release. | ||
| if ($fileName -eq "stable.json") { | ||
| [System.Management.Automation.SemanticVersion] $stableVersion = $stableReleaseTag | ||
| [System.Management.Automation.SemanticVersion] $currentVersion = $currentReleaseTag | ||
|
Comment on lines
+86
to
+87
|
||
| if ($ltsRelease) { | ||
| $ltsFile = "$ENV:PIPELINE_WORKSPACE/lts.json" | ||
| Copy-Item -Path $targetFile -Destination $ltsFile -Force | ||
| Set-BuildVariable -Name LtsBuildInfoJsonFile -Value $ltsFile | ||
| Set-BuildVariable -Name CopyLTSBuildInfo -Value YES | ||
| Set-BuildVariable -Name LTSBuildInfoFile -Value $ltsFile | ||
| Set-BuildVariable -Name UploadLTS -Value YES | ||
| } else { | ||
| Set-BuildVariable -Name CopyLTSBuildInfo -Value NO | ||
| Set-BuildVariable -Name UploadLTS -Value NO | ||
| } | ||
|
|
||
| $releaseTag = $buildInfo.ReleaseTag | ||
| $version = $releaseTag -replace '^v' | ||
| $semVersion = [System.Management.Automation.SemanticVersion] $version | ||
| ## Only update the stable.json if the current version is greater than the stable version. | ||
| if ($currentVersion -gt $stableVersion) { | ||
| $versionFile = "$ENV:PIPELINE_WORKSPACE/$($currentVersion.Major)-$($currentVersion.Minor).json" | ||
| Copy-Item -Path $targetFile -Destination $versionFile -Force | ||
| Set-BuildVariable -Name StableBuildInfoFile -Value $versionFile | ||
| Set-BuildVariable -Name UploadStable -Value YES | ||
| } else { | ||
| Set-BuildVariable -Name UploadStable -Value NO | ||
| } | ||
|
|
||
| $versionFile = "$ENV:PIPELINE_WORKSPACE/$($semVersion.Major)-$($semVersion.Minor).json" | ||
| Copy-Item -Path $targetFile -Destination $versionFile -Force | ||
| Set-BuildVariable -Name VersionBuildInfoJsonFile -Value $versionFile | ||
| Set-BuildVariable -Name CopyVersionBuildInfo -Value YES | ||
| } else { | ||
| Set-BuildVariable -Name CopyVersionBuildInfo -Value NO | ||
| Set-BuildVariable -Name UploadStable -Value NO | ||
| } | ||
| displayName: Create json files | ||
|
|
||
|
|
@@ -116,24 +123,27 @@ jobs: | |
|
|
||
| $storageContext = New-AzStorageContext -StorageAccountName $storageAccount -UseConnectedAccount | ||
|
|
||
| if ($env:CopyMainBuildInfo -eq 'YES') { | ||
| $jsonFile = "$env:BuildInfoJsonFile" | ||
| #preview | ||
| if ($env:UploadPreview -eq 'YES') { | ||
| $jsonFile = "$env:PreviewBuildInfoFile" | ||
| $blobName = Get-Item $jsonFile | Split-Path -Leaf | ||
| Write-Verbose -Verbose "Uploading $jsonFile to $containerName/$prefix/$blobName" | ||
| Set-AzStorageBlobContent -File $jsonFile -Container $containerName -Blob "$prefix/$blobName" -Context $storageContext -Force | ||
| } | ||
|
|
||
| if ($env:CopyLTSBuildInfo -eq 'YES') { | ||
| $jsonFile = "$env:LtsBuildInfoJsonFile" | ||
| #LTS | ||
| if ($env:UploadLTS -eq 'YES') { | ||
| $jsonFile = "$env:LTSBuildInfoFile" | ||
| $blobName = Get-Item $jsonFile | Split-Path -Leaf | ||
| Write-Verbose -Verbose "Uploading $jsonFile to $containerName/$prefix/$blobName" | ||
| Set-AzStorageBlobContent -File $jsonFile -Container $containerName -Blob "$prefix/$blobName" -Context $storageContext -Force | ||
| } | ||
|
|
||
| if ($env:CopyVersionBuildInfo -eq 'YES') { | ||
| $jsonFile = "$env:VersionBuildInfoJsonFile" | ||
| #stable | ||
| if ($env:UploadStable -eq 'YES') { | ||
| $jsonFile = "$env:StableBuildInfoFile" | ||
| $blobName = Get-Item $jsonFile | Split-Path -Leaf | ||
| Write-Verbose -Verbose "Uploading $jsonFile to $containerName/$prefix/$blobName" | ||
| Set-AzStorageBlobContent -File $jsonFile -Container $containerName -Blob "$prefix/$blobName" -Context $storageContext -Force | ||
| } | ||
| condition: and(succeeded(), eq(variables['CopyMainBuildInfo'], 'YES')) | ||
| condition: and(succeeded(), or(eq(variables['UploadPreview'], 'YES'), eq(variables['UploadLTS'], 'YES'), eq(variables['UploadStable'], 'YES'))) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable
$buildInfois used on line 61 before it's defined. The$buildInfoobject is not created until line 69 with$buildInfo = $buildInfoJsonContent | ConvertFrom-Json. This will cause a runtime error when the script tries to access$buildInfo.ReleaseTagon a null or undefined variable.This line should be removed as line 71 correctly sets
$currentReleaseTagafter$buildInfois defined.