Skip to content

Commit 2e6a713

Browse files
premunCopilot
andauthored
Promote NuGet.Client builds during official CI (#48311)
Co-authored-by: Copilot <[email protected]>
1 parent e8980ec commit 2e6a713

File tree

4 files changed

+126
-0
lines changed

4 files changed

+126
-0
lines changed

.vsts-ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,3 +345,7 @@ extends:
345345
name: $(DncEngInternalBuildPool)
346346
image: 1es-windows-2022
347347
os: windows
348+
349+
- template: /eng/pipelines/templates/jobs/promote-nuget-client.yml@self
350+
parameters:
351+
assetName: NuGet.Protocol
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# NuGet.Client does not flow to the VMR directly but only to dotnet/sdk where it is validated
2+
# Upon the version bump happens in dotnet/sdk, this job promotes that build of NuGet.Client to
3+
# another channel from where it flows into the VMR.
4+
# The sdk and nuget.client subscriptions are batched and go into the VMR in a single PR.
5+
# More information: https://github.com/dotnet/arcade-services/issues/4618
6+
7+
parameters:
8+
- name: assetName
9+
type: string
10+
displayName: Name of the asset to promote
11+
12+
jobs:
13+
- job: PromoteNuGetClient
14+
displayName: Promote NuGet Client
15+
pool:
16+
name: NetCore1ESPool-Publishing-Internal
17+
image: windows.vs2019.amd64
18+
os: windows
19+
20+
steps:
21+
- template: ../steps/install-darc.yml@self
22+
23+
- template: ../steps/get-asset-info.yml@self
24+
parameters:
25+
assetName: ${{ parameters.assetName }}
26+
27+
- task: AzureCLI@2
28+
displayName: 🟣 Assign build to channel
29+
inputs:
30+
azureSubscription: "Darc: Maestro Production"
31+
scriptType: ps
32+
scriptLocation: inlineScript
33+
inlineScript: |
34+
$version = '$(AssetVersion)'
35+
36+
Write-Host "Promoting build of asset ${{ parameters.assetName }} / $version..."
37+
38+
$assets = .\.dotnet\dotnet darc get-asset --name '${{ parameters.assetName }}' --version "$version" --max-age 60 --output-format json --ci
39+
$parsedAssets = $assets | ConvertFrom-Json
40+
41+
if (-not $parsedAssets -or -not $parsedAssets[0]) {
42+
Write-Error "No build found to promote version $version"
43+
exit 1
44+
}
45+
46+
$buildId = $parsedAssets[0].build.id
47+
try {
48+
$defaultChannels = .\.dotnet\dotnet darc get-default-channels --source-repo https://github.com/dotnet/sdk --branch "$(Build.SourceBranchName)" --output-format json --ci | ConvertFrom-Json
49+
} catch {
50+
Write-Host "No default channels found for branch $(Build.SourceBranchName) - no promotion will take place"
51+
exit 0
52+
}
53+
54+
if ($defaultChannels.Count -eq 0) {
55+
Write-Host "Default channels list is empty for branch $(Build.SourceBranchName) - no promotion will take place"
56+
exit 0
57+
}
58+
$targetChannel = $defaultChannels[0].channel.name
59+
60+
Write-Host "Promoting build $buildId to channel $targetChannel"
61+
62+
.\.dotnet\dotnet darc add-build-to-channel --id $buildId --channel "$targetChannel" --skip-assets-publishing --ci
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
### Looks up asset information from Version.Details.xml and stores it in variables
2+
3+
parameters:
4+
- name: assetName
5+
type: string
6+
displayName: Name of the asset to look up
7+
8+
steps:
9+
- task: AzureCLI@2
10+
displayName: 🟣 Get version information
11+
inputs:
12+
azureSubscription: "Darc: Maestro Production"
13+
scriptType: ps
14+
scriptLocation: inlineScript
15+
inlineScript: |
16+
$ErrorActionPreference = 'Stop'
17+
Write-Host "Searching for details of asset ${{ parameters.assetName }}..."
18+
19+
$dependencies = .\.dotnet\dotnet darc get-dependencies --name '${{ parameters.assetName }}' --ci
20+
$version = $dependencies | Select-String -Pattern 'Version:\s+([^\s]+)' | Select-Object -First 1
21+
22+
if ($version -eq $null) {
23+
Write-Error "Asset ${{ parameters.assetName }} not found in the dependency list"
24+
exit 1
25+
}
26+
27+
$version -match 'Version:\s+([^\s]+)' | Out-Null
28+
$version = $matches[1]
29+
30+
$repository = $dependencies | Select-String -Pattern 'Repo:\s+([^\s]+)' | Select-Object -First 1
31+
$repository -match 'Repo:\s+([^\s]+)' | Out-Null
32+
$repository = $matches[1]
33+
34+
$commit = $dependencies | Select-String -Pattern 'Commit:\s+([^\s]+)' | Select-Object -First 1
35+
$commit -match 'Commit:\s+([^\s]+)' | Out-Null
36+
$commit = $matches[1]
37+
38+
Write-Host "##vso[task.setvariable variable=AssetRepository]$repository"
39+
Write-Host "##vso[task.setvariable variable=AssetCommit]$commit"
40+
Write-Host "##vso[task.setvariable variable=AssetVersion]$version"
41+
42+
Write-Host "Asset ${{ parameters.assetName }} found with version $version, commit $commit, repository $repository"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
steps:
2+
- powershell: |
3+
$ErrorActionPreference = 'Stop'
4+
. .\eng\common\tools.ps1
5+
$dotnetRoot = InitializeDotNetCli -install:$true
6+
$dotnet = "$dotnetRoot\dotnet.exe"
7+
& "$dotnet" tool restore
8+
displayName: 🟣 Install darc (Windows)
9+
condition: eq(variables['Agent.OS'], 'Windows_NT')
10+
11+
- script: |
12+
set -e
13+
. .\eng\common\tools.sh
14+
dotnetRoot=$(InitializeDotNetCli --install)
15+
dotnet="$dotnetRoot/dotnet"
16+
$dotnet tool restore
17+
displayName: 🟣 Install darc (Unix)
18+
condition: ne(variables['Agent.OS'], 'Windows_NT')

0 commit comments

Comments
 (0)