Skip to content

Commit f3b2b05

Browse files
authored
[release/6.0] Switch to dSAS for internal runtimes (#56487)
* Update arcade * Switch to dSAS for internal runtimes * Remove cred templates from public jobs * Enable internal sources for source build
1 parent 0661142 commit f3b2b05

19 files changed

+307
-38
lines changed

.azure/pipelines/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ variables:
7575
value: /bl:artifacts/log/Release/Build.Installers.binlog
7676
- name: WindowsArm64InstallersLogArgs
7777
value: /bl:artifacts/log/Release/Build.Installers.Arm64.binlog
78-
- group: DotNetBuilds storage account read tokens
7978
- name: _InternalRuntimeDownloadArgs
8079
value: -RuntimeSourceFeed https://dotnetbuilds.blob.core.windows.net/internal
8180
-RuntimeSourceFeedKey $(dotnetbuilds-internal-container-read-token-base64)
@@ -750,6 +749,7 @@ extends:
750749
# Source build
751750
- template: /eng/common/templates-official/job/source-build.yml@self
752751
parameters:
752+
enableInternalSources: true
753753
platform:
754754
name: 'Managed'
755755
container: 'mcr.microsoft.com/dotnet-buildtools/prereqs:centos-7'

.azure/pipelines/jobs/default-build.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ jobs:
199199
# Include the variables we always want.
200200
COMPlus_DbgEnableMiniDump: 1
201201
COMPlus_DbgMiniDumpName: "$(System.DefaultWorkingDirectory)/dotnet-%d.%t.core"
202-
DotNetBuildsInternalReadSasToken: $(dotnetbuilds-internal-container-read-token)
203202
# Expand provided `env:` properties, if any.
204203
${{ if step.env }}:
205204
${{ step.env }}
@@ -210,14 +209,12 @@ jobs:
210209
env:
211210
COMPlus_DbgEnableMiniDump: 1
212211
COMPlus_DbgMiniDumpName: "$(System.DefaultWorkingDirectory)/dotnet-%d.%t.core"
213-
DotNetBuildsInternalReadSasToken: $(dotnetbuilds-internal-container-read-token)
214212
- ${{ if ne(parameters.agentOs, 'Windows') }}:
215213
- script: $(BuildDirectory)/build.sh --ci --nobl --configuration $(BuildConfiguration) $(BuildScriptArgs)
216214
displayName: Run build.sh
217215
env:
218216
COMPlus_DbgEnableMiniDump: 1
219217
COMPlus_DbgMiniDumpName: "$(System.DefaultWorkingDirectory)/dotnet-%d.%t.core"
220-
DotNetBuildsInternalReadSasToken: $(dotnetbuilds-internal-container-read-token)
221218

222219
- ${{ parameters.afterBuild }}
223220

@@ -430,6 +427,20 @@ jobs:
430427
env:
431428
Token: $(dn-bot-dnceng-artifact-feeds-rw)
432429

430+
# Populates internal runtime SAS tokens.
431+
- template: /eng/common/templates-official/steps/enable-internal-runtimes.yml
432+
433+
# Populate dotnetbuilds-internal base64 sas tokens.
434+
- template: /eng/common/templates-official/steps/get-delegation-sas.yml
435+
parameters:
436+
federatedServiceConnection: 'dotnetbuilds-internal-read'
437+
outputVariableName: 'dotnetbuilds-internal-container-read-token'
438+
expiryInHours: 1
439+
base64Encode: false
440+
storageAccount: dotnetbuilds
441+
container: internal
442+
permissions: rl
443+
433444
# Add COMPlus_* environment variables to build steps.
434445
- ${{ if ne(parameters.steps, '')}}:
435446
- ${{ each step in parameters.steps }}:

eng/Version.Details.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -280,22 +280,22 @@
280280
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
281281
<Sha>1b9707a1fa56abb49ac8a286fd89a91527b6c7d3</Sha>
282282
</Dependency>
283-
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="6.0.0-beta.24266.4">
283+
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="6.0.0-beta.24326.2">
284284
<Uri>https://github.com/dotnet/arcade</Uri>
285-
<Sha>2eab07c3d7b78219d10099b19fafeef2ecae1779</Sha>
285+
<Sha>1844d819e6f33f1106083c5066ea01e0310eefa3</Sha>
286286
<SourceBuild RepoName="arcade" ManagedOnly="true" />
287287
</Dependency>
288-
<Dependency Name="Microsoft.DotNet.Build.Tasks.Installers" Version="6.0.0-beta.24266.4">
288+
<Dependency Name="Microsoft.DotNet.Build.Tasks.Installers" Version="6.0.0-beta.24326.2">
289289
<Uri>https://github.com/dotnet/arcade</Uri>
290-
<Sha>2eab07c3d7b78219d10099b19fafeef2ecae1779</Sha>
290+
<Sha>1844d819e6f33f1106083c5066ea01e0310eefa3</Sha>
291291
</Dependency>
292-
<Dependency Name="Microsoft.DotNet.Build.Tasks.Templating" Version="6.0.0-beta.24266.4">
292+
<Dependency Name="Microsoft.DotNet.Build.Tasks.Templating" Version="6.0.0-beta.24326.2">
293293
<Uri>https://github.com/dotnet/arcade</Uri>
294-
<Sha>2eab07c3d7b78219d10099b19fafeef2ecae1779</Sha>
294+
<Sha>1844d819e6f33f1106083c5066ea01e0310eefa3</Sha>
295295
</Dependency>
296-
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="6.0.0-beta.24266.4">
296+
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="6.0.0-beta.24326.2">
297297
<Uri>https://github.com/dotnet/arcade</Uri>
298-
<Sha>2eab07c3d7b78219d10099b19fafeef2ecae1779</Sha>
298+
<Sha>1844d819e6f33f1106083c5066ea01e0310eefa3</Sha>
299299
</Dependency>
300300
</ToolsetDependencies>
301301
</Dependencies>

eng/Versions.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@
131131
<MicrosoftEntityFrameworkCoreVersion>6.0.30</MicrosoftEntityFrameworkCoreVersion>
132132
<MicrosoftEntityFrameworkCoreDesignVersion>6.0.30</MicrosoftEntityFrameworkCoreDesignVersion>
133133
<!-- Packages from dotnet/arcade -->
134-
<MicrosoftDotNetBuildTasksInstallersVersion>6.0.0-beta.24266.4</MicrosoftDotNetBuildTasksInstallersVersion>
135-
<MicrosoftDotNetBuildTasksTemplatingVersion>6.0.0-beta.24266.4</MicrosoftDotNetBuildTasksTemplatingVersion>
134+
<MicrosoftDotNetBuildTasksInstallersVersion>6.0.0-beta.24326.2</MicrosoftDotNetBuildTasksInstallersVersion>
135+
<MicrosoftDotNetBuildTasksTemplatingVersion>6.0.0-beta.24326.2</MicrosoftDotNetBuildTasksTemplatingVersion>
136136
</PropertyGroup>
137137
<!--
138138

eng/common/templates-official/job/source-build.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ parameters:
3131
# container and pool.
3232
platform: {}
3333

34+
# If set to true and running on a non-public project,
35+
# Internal blob storage locations will be enabled.
36+
# This is not enabled by default because many repositories do not need internal sources
37+
# and do not need to have the required service connections approved in the pipeline.
38+
enableInternalSources: false
39+
3440
jobs:
3541
- job: ${{ parameters.jobNamePrefix }}_${{ parameters.platform.name }}
3642
displayName: Source-Build (${{ parameters.platform.name }})
@@ -59,6 +65,8 @@ jobs:
5965
clean: all
6066

6167
steps:
68+
- ${{ if eq(parameters.enableInternalSources, true) }}:
69+
- template: /eng/common/templates-official/steps/enable-internal-runtimes.yml
6270
- template: /eng/common/templates-official/steps/source-build.yml
6371
parameters:
6472
platform: ${{ parameters.platform }}

eng/common/templates-official/job/source-index-stage1.yml

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
parameters:
22
runAsPublic: false
3-
sourceIndexPackageVersion: 1.0.1-20240320.1
3+
sourceIndexUploadPackageVersion: 2.0.0-20240502.12
4+
sourceIndexProcessBinlogPackageVersion: 1.0.1-20240129.2
45
sourceIndexPackageSource: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json
56
sourceIndexBuildCommand: powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -Command "eng/common/build.ps1 -restore -build -binarylog -ci"
67
preSteps: []
@@ -17,14 +18,14 @@ jobs:
1718
dependsOn: ${{ parameters.dependsOn }}
1819
condition: ${{ parameters.condition }}
1920
variables:
20-
- name: SourceIndexPackageVersion
21-
value: ${{ parameters.sourceIndexPackageVersion }}
21+
- name: SourceIndexUploadPackageVersion
22+
value: ${{ parameters.sourceIndexUploadPackageVersion }}
23+
- name: SourceIndexProcessBinlogPackageVersion
24+
value: ${{ parameters.sourceIndexProcessBinlogPackageVersion }}
2225
- name: SourceIndexPackageSource
2326
value: ${{ parameters.sourceIndexPackageSource }}
2427
- name: BinlogPath
2528
value: ${{ parameters.binlogPath }}
26-
- ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
27-
- group: source-dot-net stage1 variables
2829

2930
pool: ${{ parameters.pool }}
3031
steps:
@@ -40,8 +41,8 @@ jobs:
4041
workingDirectory: $(Agent.TempDirectory)
4142

4243
- script: |
43-
$(Agent.TempDirectory)/dotnet/dotnet tool install BinLogToSln --version $(SourceIndexPackageVersion) --add-source $(SourceIndexPackageSource) --tool-path $(Agent.TempDirectory)/.source-index/tools
44-
$(Agent.TempDirectory)/dotnet/dotnet tool install UploadIndexStage1 --version $(SourceIndexPackageVersion) --add-source $(SourceIndexPackageSource) --tool-path $(Agent.TempDirectory)/.source-index/tools
44+
$(Agent.TempDirectory)/dotnet/dotnet tool install BinLogToSln --version $(sourceIndexProcessBinlogPackageVersion) --add-source $(SourceIndexPackageSource) --tool-path $(Agent.TempDirectory)/.source-index/tools
45+
$(Agent.TempDirectory)/dotnet/dotnet tool install UploadIndexStage1 --version $(sourceIndexUploadPackageVersion) --add-source $(SourceIndexPackageSource) --tool-path $(Agent.TempDirectory)/.source-index/tools
4546
displayName: Download Tools
4647
# Set working directory to temp directory so 'dotnet' doesn't try to use global.json and use the repo's sdk.
4748
workingDirectory: $(Agent.TempDirectory)
@@ -53,7 +54,21 @@ jobs:
5354
displayName: Process Binlog into indexable sln
5455

5556
- ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
56-
- script: $(Agent.TempDirectory)/.source-index/tools/UploadIndexStage1 -i .source-index/stage1output -n $(Build.Repository.Name)
57+
- task: AzureCLI@2
58+
displayName: Get stage 1 auth token
59+
inputs:
60+
azureSubscription: 'SourceDotNet Stage1 Publish'
61+
addSpnToEnvironment: true
62+
scriptType: 'ps'
63+
scriptLocation: 'inlineScript'
64+
inlineScript: |
65+
echo "##vso[task.setvariable variable=ARM_CLIENT_ID;issecret=true]$env:servicePrincipalId"
66+
echo "##vso[task.setvariable variable=ARM_ID_TOKEN;issecret=true]$env:idToken"
67+
echo "##vso[task.setvariable variable=ARM_TENANT_ID;issecret=true]$env:tenantId"
68+
69+
- script: |
70+
az login --service-principal -u $(ARM_CLIENT_ID) --tenant $(ARM_TENANT_ID) --allow-no-subscriptions --federated-token $(ARM_ID_TOKEN)
71+
displayName: "Login to Azure"
72+
73+
- script: $(Agent.TempDirectory)/.source-index/tools/UploadIndexStage1 -i .source-index/stage1output -n $(Build.Repository.Name) -s netsourceindexstage1 -b stage1
5774
displayName: Upload stage1 artifacts to source index
58-
env:
59-
BLOB_CONTAINER_URL: $(source-dot-net-stage1-blob-container-url)

eng/common/templates-official/jobs/source-build.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ parameters:
2121
# one job runs on 'defaultManagedPlatform'.
2222
platforms: []
2323

24+
# If set to true and running on a non-public project,
25+
# Internal nuget and blob storage locations will be enabled.
26+
# This is not enabled by default because many repositories do not need internal sources
27+
# and do not need to have the required service connections approved in the pipeline.
28+
enableInternalSources: false
29+
2430
jobs:
2531

2632
- ${{ if ne(parameters.allCompletedJobId, '') }}:
@@ -38,9 +44,11 @@ jobs:
3844
parameters:
3945
jobNamePrefix: ${{ parameters.jobNamePrefix }}
4046
platform: ${{ platform }}
47+
enableInternalSources: ${{ parameters.enableInternalSources }}
4148

4249
- ${{ if eq(length(parameters.platforms), 0) }}:
4350
- template: /eng/common/templates-official/job/source-build.yml
4451
parameters:
4552
jobNamePrefix: ${{ parameters.jobNamePrefix }}
4653
platform: ${{ parameters.defaultManagedPlatform }}
54+
enableInternalSources: ${{ parameters.enableInternalSources }}

eng/common/templates-official/post-build/common-variables.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ variables:
22
- group: AzureDevOps-Artifact-Feeds-Pats
33
- group: DotNet-Blob-Feed
44
- group: DotNet-DotNetCli-Storage
5-
- group: DotNet-MSRC-Storage
65
- group: Publish-Build-Assets
76

87
# Whether the build is internal or not
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Obtains internal runtime download credentials and populates the 'dotnetbuilds-internal-container-read-token-base64'
2+
# variable with the base64-encoded SAS token, by default
3+
4+
parameters:
5+
- name: federatedServiceConnection
6+
type: string
7+
default: 'dotnetbuilds-internal-read'
8+
- name: outputVariableName
9+
type: string
10+
default: 'dotnetbuilds-internal-container-read-token-base64'
11+
- name: expiryInHours
12+
type: number
13+
default: 1
14+
- name: base64Encode
15+
type: boolean
16+
default: true
17+
18+
steps:
19+
- ${{ if ne(variables['System.TeamProject'], 'public') }}:
20+
- template: /eng/common/templates-official/steps/get-delegation-sas.yml
21+
parameters:
22+
federatedServiceConnection: ${{ parameters.federatedServiceConnection }}
23+
outputVariableName: ${{ parameters.outputVariableName }}
24+
expiryInHours: ${{ parameters.expiryInHours }}
25+
base64Encode: ${{ parameters.base64Encode }}
26+
storageAccount: dotnetbuilds
27+
container: internal
28+
permissions: rl
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
parameters:
2+
- name: federatedServiceConnection
3+
type: string
4+
- name: outputVariableName
5+
type: string
6+
- name: expiryInHours
7+
type: number
8+
default: 1
9+
- name: base64Encode
10+
type: boolean
11+
default: false
12+
- name: storageAccount
13+
type: string
14+
- name: container
15+
type: string
16+
- name: permissions
17+
type: string
18+
default: 'rl'
19+
20+
steps:
21+
- task: AzureCLI@2
22+
displayName: 'Generate delegation SAS Token for ${{ parameters.storageAccount }}/${{ parameters.container }}'
23+
inputs:
24+
azureSubscription: ${{ parameters.federatedServiceConnection }}
25+
scriptType: 'pscore'
26+
scriptLocation: 'inlineScript'
27+
inlineScript: |
28+
# Calculate the expiration of the SAS token and convert to UTC
29+
$expiry = (Get-Date).AddHours(${{ parameters.expiryInHours }}).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
30+
31+
$sas = az storage container generate-sas --account-name ${{ parameters.storageAccount }} --name ${{ parameters.container }} --permissions ${{ parameters.permissions }} --expiry $expiry --auth-mode login --as-user -o tsv
32+
33+
if ($LASTEXITCODE -ne 0) {
34+
Write-Error "Failed to generate SAS token."
35+
exit 1
36+
}
37+
38+
if ('${{ parameters.base64Encode }}' -eq 'true') {
39+
$sas = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($sas))
40+
}
41+
42+
Write-Host "Setting '${{ parameters.outputVariableName }}' with the access token value"
43+
Write-Host "##vso[task.setvariable variable=${{ parameters.outputVariableName }};issecret=true]$sas"

0 commit comments

Comments
 (0)