1- # ################################################################################
2- # Licensed to the .NET Foundation under one or more agreements. #
3- # The .NET Foundation licenses this file to you under the MIT license. #
4- # See the LICENSE file in the project root for more information. #
5- # ################################################################################
1+ # ###################################################################################
2+ # Licensed to the .NET Foundation under one or more agreements. #
3+ # The .NET Foundation licenses this file to you under the MIT license. #
4+ # See the LICENSE file in the project root for more information. #
5+ # #
6+ # doc: https://www.osgwiki.com/wiki/Symbols_Publishing_Pipeline_to_SymWeb_and_MSDL #
7+ # ###################################################################################
68parameters :
79 - name : SymAccount
810 type : string
11+ default : ' SqlClientDrivers'
912
1013 - name : publishSymbols
1114 type : string
@@ -15,6 +18,23 @@ parameters:
1518 type : string
1619 default : ' $(NuGetPackageVersion)'
1720
21+ - name : symbolServer
22+ type : string
23+ default : ' $(SymbolServer)'
24+
25+ - name : symbolTokenUri
26+ type : string
27+ default : ' $(SymbolTokenUri)'
28+
29+ - name : symbolsArtifactName
30+ type : string
31+
32+ - name : publishToServers
33+ type : object
34+ default :
35+ internal : true
36+ public : true
37+
1838 - name : referenceType
1939 default : project
2040 values :
@@ -29,12 +49,12 @@ parameters:
2949
3050steps :
3151- powershell : ' Write-Host "##vso[task.setvariable variable=ArtifactServices.Symbol.AccountName;]${{parameters.SymAccount}}"'
32- displayName : ' Update Symbol.AccountName ${{parameters.SymAccount}}'
52+ displayName : ' Update Symbol.AccountName with ${{parameters.SymAccount}}'
3353 condition : and(succeeded(), ${{ eq(parameters.publishSymbols, 'true') }})
3454
3555- ${{ if eq(parameters.product, 'MDS') }} :
3656 - task : PublishSymbols@2
37- displayName : ' Publish symbols path '
57+ displayName : ' Upload symbols to ${{parameters.SymAccount }} org '
3858 inputs :
3959 SymbolsFolder : ' $(Build.SourcesDirectory)\artifacts\${{parameters.referenceType }}\bin'
4060 SearchPattern : |
@@ -43,13 +63,16 @@ steps:
4363 IndexSources : false
4464 SymbolServerType : TeamServices
4565 SymbolsMaximumWaitTime : 60
66+ SymbolExpirationInDays : 1825 # 5 years
4667 SymbolsProduct : Microsoft.Data.SqlClient
47- SymbolsVersion : ' {{parameters.symbolsVersion }}'
68+ SymbolsVersion : ${{parameters.symbolsVersion }}
69+ SymbolsArtifactName : ${{parameters.symbolsArtifactName }}
70+ Pat : $(System.AccessToken)
4871 condition : and(succeeded(), ${{ eq(parameters.publishSymbols, 'true') }})
4972
5073- ${{ if eq(parameters.product, 'AKV') }} :
5174 - task : PublishSymbols@2
52- displayName : ' Publish symbols path '
75+ displayName : ' Upload symbols to ${{parameters.SymAccount }} org '
5376 inputs :
5477 SymbolsFolder : ' $(Build.SourcesDirectory)\artifacts\${{parameters.referenceType }}\bin'
5578 SearchPattern : |
@@ -58,6 +81,69 @@ steps:
5881 IndexSources : false
5982 SymbolServerType : TeamServices
6083 SymbolsMaximumWaitTime : 60
84+ SymbolExpirationInDays : 1825 # 5 years
6185 SymbolsProduct : Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider
62- SymbolsVersion : ' {{parameters.symbolsVersion }}'
86+ SymbolsVersion : ${{parameters.symbolsVersion }}
87+ SymbolsArtifactName : ${{parameters.symbolsArtifactName }}
88+ Pat : $(System.AccessToken)
6389 condition : and(succeeded(), ${{ eq(parameters.publishSymbols, 'true') }})
90+
91+ - task : AzureCLI@2
92+ displayName : ' Publish symbols'
93+ condition : and(succeeded(), ${{ eq(parameters.publishSymbols, 'true') }})
94+ inputs :
95+ azureSubscription : ' Symbols publishing Workload Identity federation service-ADO.Net'
96+ scriptType : ps
97+ scriptLocation : inlineScript
98+ inlineScript : |
99+ $publishToInternalServer = "${{parameters.publishToServers.internal }}".ToLower()
100+ $publishToPublicServer = "${{parameters.publishToServers.public }}".ToLower()
101+
102+ echo "Publishing request name: ${{parameters.symbolsArtifactName }}"
103+ echo "Publish to internal server: $publishToInternalServer"
104+ echo "Publish to public server: $publishToPublicServer"
105+
106+ $symbolServer = "${{parameters.symbolServer }}"
107+ $tokenUri = "${{parameters.symbolTokenUri }}"
108+ # Registered project name in the symbol publishing pipeline: https://portal.microsofticm.com/imp/v3/incidents/incident/520844254/summary
109+ $projectName = "Microsoft.Data.SqlClient.SNI"
110+
111+ # Get the access token for the symbol publishing service
112+ $symbolPublishingToken = az account get-access-token --resource $tokenUri --query accessToken -o tsv
113+
114+ echo "> 1.Symbol publishing token acquired."
115+
116+ echo "Registering the request name ..."
117+ $requestName = "${{parameters.symbolsArtifactName }}"
118+ $requestNameRegistrationBody = "{'requestName': '$requestName'}"
119+ Invoke-RestMethod -Method POST -Uri "https://$symbolServer.trafficmanager.net/projects/$projectName/requests" -Headers @{ Authorization = "Bearer $symbolPublishingToken" } -ContentType "application/json" -Body $requestNameRegistrationBody
120+
121+ echo "> 2.Registration of request name succeeded."
122+
123+ echo "Publishing the symbols ..."
124+ $publishSymbolsBody = "{'publishToInternalServer': $publishToInternalServer, 'publishToPublicServer': $publishToPublicServer}"
125+ echo "Publishing symbols request body: $publishSymbolsBody"
126+ Invoke-RestMethod -Method POST -Uri "https://$symbolServer.trafficmanager.net/projects/$projectName/requests/$requestName" -Headers @{ Authorization = "Bearer $symbolPublishingToken" } -ContentType "application/json" -Body $publishSymbolsBody
127+
128+ echo "> 3.Request to publish symbols succeeded."
129+
130+ # The following REST calls are used to check publishing status.
131+ echo "> 4.Checking the status of the request ..."
132+
133+ Invoke-RestMethod -Method GET -Uri "https://$symbolServer.trafficmanager.net/projects/$projectName/requests/$requestName" -Headers @{ Authorization = "Bearer $symbolPublishingToken" } -ContentType "application/json"
134+
135+ echo "Use below tables to interpret the values of xxxServerStatus and xxxServerResult fields from the response."
136+
137+ echo "PublishingStatus"
138+ echo "-----------------"
139+ echo "0 NotRequested; The request has not been requested to publish."
140+ echo "1 Submitted; The request is submitted to be published"
141+ echo "2 Processing; The request is still being processed"
142+ echo "3 Completed; The request has been completed processing. It can be failed or successful. Check PublishingResult to get more details"
143+
144+ echo "PublishingResult"
145+ echo "-----------------"
146+ echo "0 Pending; The request has not completed or has not been requested."
147+ echo "1 Succeeded; The request has published successfully"
148+ echo "2 Failed; The request has failed to publish"
149+ echo "3 Cancelled; The request was cancelled"
0 commit comments