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
+ # ###################################################################################
6
8
parameters :
7
9
- name : SymAccount
8
10
type : string
11
+ default : ' SqlClientDrivers'
9
12
10
13
- name : publishSymbols
11
14
type : string
@@ -15,6 +18,23 @@ parameters:
15
18
type : string
16
19
default : ' $(NuGetPackageVersion)'
17
20
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
+
18
38
- name : referenceType
19
39
default : project
20
40
values :
@@ -30,12 +50,12 @@ parameters:
30
50
31
51
steps :
32
52
- powershell : ' Write-Host "##vso[task.setvariable variable=ArtifactServices.Symbol.AccountName;]${{parameters.SymAccount}}"'
33
- displayName : ' Update Symbol.AccountName ${{parameters.SymAccount}}'
53
+ displayName : ' Update Symbol.AccountName with ${{parameters.SymAccount}}'
34
54
condition : and(succeeded(), ${{ eq(parameters.publishSymbols, 'true') }})
35
55
36
56
- ${{ if eq(parameters.product, 'MDS') }} :
37
57
- task : PublishSymbols@2
38
- displayName : ' Publish symbols path '
58
+ displayName : ' Upload symbols to ${{parameters.SymAccount }} org '
39
59
inputs :
40
60
SymbolsFolder : ' $(Build.SourcesDirectory)\artifacts\${{parameters.referenceType }}\bin'
41
61
SearchPattern : |
@@ -44,13 +64,16 @@ steps:
44
64
IndexSources : false
45
65
SymbolServerType : TeamServices
46
66
SymbolsMaximumWaitTime : 60
67
+ SymbolExpirationInDays : 1825 # 5 years
47
68
SymbolsProduct : Microsoft.Data.SqlClient
48
- SymbolsVersion : ' {{parameters.symbolsVersion }}'
69
+ SymbolsVersion : ${{parameters.symbolsVersion }}
70
+ SymbolsArtifactName : ${{parameters.symbolsArtifactName }}
71
+ Pat : $(System.AccessToken)
49
72
condition : and(succeeded(), ${{ eq(parameters.publishSymbols, 'true') }})
50
73
51
74
- ${{ if eq(parameters.product, 'AKV') }} :
52
75
- task : PublishSymbols@2
53
- displayName : ' Publish symbols path '
76
+ displayName : ' Upload symbols to ${{parameters.SymAccount }} org '
54
77
inputs :
55
78
SymbolsFolder : ' $(Build.SourcesDirectory)\artifacts\${{parameters.referenceType }}\bin'
56
79
SearchPattern : |
@@ -59,6 +82,69 @@ steps:
59
82
IndexSources : false
60
83
SymbolServerType : TeamServices
61
84
SymbolsMaximumWaitTime : 60
85
+ SymbolExpirationInDays : 1825 # 5 years
62
86
SymbolsProduct : Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider
63
- SymbolsVersion : ' {{parameters.symbolsVersion }}'
87
+ SymbolsVersion : ${{parameters.symbolsVersion }}
88
+ SymbolsArtifactName : ${{parameters.symbolsArtifactName }}
89
+ Pat : $(System.AccessToken)
64
90
condition : and(succeeded(), ${{ eq(parameters.publishSymbols, 'true') }})
91
+
92
+ - task : AzureCLI@2
93
+ displayName : ' Publish symbols'
94
+ condition : and(succeeded(), ${{ eq(parameters.publishSymbols, 'true') }})
95
+ inputs :
96
+ azureSubscription : ' Symbols publishing Workload Identity federation service-ADO.Net'
97
+ scriptType : ps
98
+ scriptLocation : inlineScript
99
+ inlineScript : |
100
+ $publishToInternalServer = "${{parameters.publishToServers.internal }}".ToLower()
101
+ $publishToPublicServer = "${{parameters.publishToServers.public }}".ToLower()
102
+
103
+ echo "Publishing request name: ${{parameters.symbolsArtifactName }}"
104
+ echo "Publish to internal server: $publishToInternalServer"
105
+ echo "Publish to public server: $publishToPublicServer"
106
+
107
+ $symbolServer = "${{parameters.symbolServer }}"
108
+ $tokenUri = "${{parameters.symbolTokenUri }}"
109
+ # Registered project name in the symbol publishing pipeline: https://portal.microsofticm.com/imp/v3/incidents/incident/520844254/summary
110
+ $projectName = "Microsoft.Data.SqlClient.SNI"
111
+
112
+ # Get the access token for the symbol publishing service
113
+ $symbolPublishingToken = az account get-access-token --resource $tokenUri --query accessToken -o tsv
114
+
115
+ echo "> 1.Symbol publishing token acquired."
116
+
117
+ echo "Registering the request name ..."
118
+ $requestName = "${{parameters.symbolsArtifactName }}"
119
+ $requestNameRegistrationBody = "{'requestName': '$requestName'}"
120
+ Invoke-RestMethod -Method POST -Uri "https://$symbolServer.trafficmanager.net/projects/$projectName/requests" -Headers @{ Authorization = "Bearer $symbolPublishingToken" } -ContentType "application/json" -Body $requestNameRegistrationBody
121
+
122
+ echo "> 2.Registration of request name succeeded."
123
+
124
+ echo "Publishing the symbols ..."
125
+ $publishSymbolsBody = "{'publishToInternalServer': $publishToInternalServer, 'publishToPublicServer': $publishToPublicServer}"
126
+ echo "Publishing symbols request body: $publishSymbolsBody"
127
+ Invoke-RestMethod -Method POST -Uri "https://$symbolServer.trafficmanager.net/projects/$projectName/requests/$requestName" -Headers @{ Authorization = "Bearer $symbolPublishingToken" } -ContentType "application/json" -Body $publishSymbolsBody
128
+
129
+ echo "> 3.Request to publish symbols succeeded."
130
+
131
+ # The following REST calls are used to check publishing status.
132
+ echo "> 4.Checking the status of the request ..."
133
+
134
+ Invoke-RestMethod -Method GET -Uri "https://$symbolServer.trafficmanager.net/projects/$projectName/requests/$requestName" -Headers @{ Authorization = "Bearer $symbolPublishingToken" } -ContentType "application/json"
135
+
136
+ echo "Use below tables to interpret the values of xxxServerStatus and xxxServerResult fields from the response."
137
+
138
+ echo "PublishingStatus"
139
+ echo "-----------------"
140
+ echo "0 NotRequested; The request has not been requested to publish."
141
+ echo "1 Submitted; The request is submitted to be published"
142
+ echo "2 Processing; The request is still being processed"
143
+ echo "3 Completed; The request has been completed processing. It can be failed or successful. Check PublishingResult to get more details"
144
+
145
+ echo "PublishingResult"
146
+ echo "-----------------"
147
+ echo "0 Pending; The request has not completed or has not been requested."
148
+ echo "1 Succeeded; The request has published successfully"
149
+ echo "2 Failed; The request has failed to publish"
150
+ echo "3 Cancelled; The request was cancelled"
0 commit comments