Skip to content

Commit 73adbdc

Browse files
author
Mirroring
committed
Merge commit 'd20ce761422e7178512bb89bfa3fdce797924616'
2 parents dc9cf7d + d20ce76 commit 73adbdc

16 files changed

+288
-30
lines changed

eng/Version.Details.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@
4747
</Dependency>
4848
</ProductDependencies>
4949
<ToolsetDependencies>
50-
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="6.0.0-beta.24266.4">
50+
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="6.0.0-beta.24360.7">
5151
<Uri>https://github.com/dotnet/arcade</Uri>
52-
<Sha>2eab07c3d7b78219d10099b19fafeef2ecae1779</Sha>
52+
<Sha>fbc993a9e8fb4926ce04c95ba2e48852c9d9df65</Sha>
5353
</Dependency>
54-
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="6.0.0-beta.24266.4">
54+
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="6.0.0-beta.24360.7">
5555
<Uri>https://github.com/dotnet/arcade</Uri>
56-
<Sha>2eab07c3d7b78219d10099b19fafeef2ecae1779</Sha>
56+
<Sha>fbc993a9e8fb4926ce04c95ba2e48852c9d9df65</Sha>
5757
</Dependency>
5858
</ToolsetDependencies>
5959
</Dependencies>

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"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
parameters:
2+
- name: federatedServiceConnection
3+
type: string
4+
- name: outputVariableName
5+
type: string
6+
# Resource to get a token for. Common values include:
7+
# - '499b84ac-1321-427f-aa17-267ca6975798' for Azure DevOps
8+
# - 'https://storage.azure.com/' for storage
9+
# Defaults to Azure DevOps
10+
- name: resource
11+
type: string
12+
default: '499b84ac-1321-427f-aa17-267ca6975798'
13+
14+
steps:
15+
- task: AzureCLI@2
16+
displayName: 'Getting federated access token for feeds'
17+
inputs:
18+
azureSubscription: ${{ parameters.federatedServiceConnection }}
19+
scriptType: 'pscore'
20+
scriptLocation: 'inlineScript'
21+
inlineScript: |
22+
$accessToken = az account get-access-token --query accessToken --resource ${{ parameters.resource }} --output tsv
23+
if ($LASTEXITCODE -ne 0) {
24+
Write-Error "Failed to get access token for resource '${{ parameters.resource }}'"
25+
exit 1
26+
}
27+
Write-Host "Setting '${{ parameters.outputVariableName }}' with the access token value"
28+
Write-Host "##vso[task.setvariable variable=${{ parameters.outputVariableName }};issecret=true]$accessToken"

eng/common/templates/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 }})
@@ -58,6 +64,8 @@ jobs:
5864
clean: all
5965

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

eng/common/templates/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: []
@@ -15,14 +16,14 @@ jobs:
1516
dependsOn: ${{ parameters.dependsOn }}
1617
condition: ${{ parameters.condition }}
1718
variables:
18-
- name: SourceIndexPackageVersion
19-
value: ${{ parameters.sourceIndexPackageVersion }}
19+
- name: SourceIndexUploadPackageVersion
20+
value: ${{ parameters.sourceIndexUploadPackageVersion }}
21+
- name: SourceIndexProcessBinlogPackageVersion
22+
value: ${{ parameters.sourceIndexProcessBinlogPackageVersion }}
2023
- name: SourceIndexPackageSource
2124
value: ${{ parameters.sourceIndexPackageSource }}
2225
- name: BinlogPath
2326
value: ${{ parameters.binlogPath }}
24-
- ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
25-
- group: source-dot-net stage1 variables
2627

2728
pool: ${{ parameters.pool }}
2829
steps:
@@ -38,8 +39,8 @@ jobs:
3839
workingDirectory: $(Agent.TempDirectory)
3940

4041
- script: |
41-
$(Agent.TempDirectory)/dotnet/dotnet tool install BinLogToSln --version $(SourceIndexPackageVersion) --add-source $(SourceIndexPackageSource) --tool-path $(Agent.TempDirectory)/.source-index/tools
42-
$(Agent.TempDirectory)/dotnet/dotnet tool install UploadIndexStage1 --version $(SourceIndexPackageVersion) --add-source $(SourceIndexPackageSource) --tool-path $(Agent.TempDirectory)/.source-index/tools
42+
$(Agent.TempDirectory)/dotnet/dotnet tool install BinLogToSln --version $(sourceIndexProcessBinlogPackageVersion) --add-source $(SourceIndexPackageSource) --tool-path $(Agent.TempDirectory)/.source-index/tools
43+
$(Agent.TempDirectory)/dotnet/dotnet tool install UploadIndexStage1 --version $(sourceIndexUploadPackageVersion) --add-source $(SourceIndexPackageSource) --tool-path $(Agent.TempDirectory)/.source-index/tools
4344
displayName: Download Tools
4445
# Set working directory to temp directory so 'dotnet' doesn't try to use global.json and use the repo's sdk.
4546
workingDirectory: $(Agent.TempDirectory)
@@ -51,7 +52,21 @@ jobs:
5152
displayName: Process Binlog into indexable sln
5253

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

0 commit comments

Comments
 (0)