-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathazure-pipelines.yml
221 lines (190 loc) · 7.77 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
trigger:
branches:
include:
- main
paths:
include:
- 'azure-pipelines.yml'
- 'src/Console/**/*'
# - 'src/Ajax/**/*'
# - 'src/Blazor/**/*'
# - 'src/Uwp/**/*'
jobs:
# *************************************************************** #
# * EXAMPLE - Uses Akeyless for credentials - * #
# *************************************************************** #
- job: BuildConsoleApp
pool:
vmImage: 'windows-2022'
variables:
consoleNugetConfigPath: 'src/nuget.config'
consoleProjectPath: 'src/Console/MyDocProcApp/MyDocProcApp.csproj'
steps:
- task: AzureCLI@2
name: 'AzureCLI'
displayName: 'Get JWT from Azure Service Principal'
inputs:
azureSubscription: 'Azure MSA Account'
scriptType: ps
scriptLocation: inlineScript
inlineScript: |
# Get a JWT using the azure CLI
$JWT=$(az account get-access-token --query accessToken --output tsv)
# Set an output variable
echo "##vso[task.setvariable variable=azure_jwt;isoutput=true;issecret=true]$JWT"
# Needs JWT, see https://github.com/LanceMcCarthy/akeyless-extension-azdo/blob/main/docs/getting-started.md
- task: akeyless-secrets@1
name: 'Akeyless1'
displayName: 'Get Secrets from Akeyless'
inputs:
accessid: '$(AKEYLESS_ACCESS_ID)'
azureJwt: '$(AzureCLI.azure_jwt)'
staticSecrets: '{"/personal-keys/mccarthy/TELERIK_NUGET_KEY":"NUGET_KEY"}'
- task: UseDotNet@2
inputs:
packageType: 'sdk'
version: '8.0.x'
- powershell: dotnet nuget update source 'Telerik' --source 'https://nuget.telerik.com/v3/index.json' --username 'api-key' --password '$(Akeyless1.NUGET_KEY)' --configfile $(consoleNugetConfigPath) --store-password-in-clear-text
displayName: 'Update package source credentials'
- powershell: dotnet restore $(consoleProjectPath) --configfile $(consoleNugetConfigPath)
displayName: 'restore packages'
- powershell: dotnet publish $(consoleProjectPath) -o /app/publish /p:UseAppHost=false --no-restore
displayName: 'Publish the project'
# *************************************************************** #
# * EXAMPLE - CONSOLE (.NET) * #
# * * #
# * -Uses Service Principal for credentials- * #
# *************************************************************** #
# - job: BuildConsoleApp
# pool:
# vmImage: 'windows-2022'
# variables:
# - group: KeyVaultVariables
# - name: consoleNugetConfigPath
# value: 'src/nuget.config'
# - name: consoleProjectPath
# value: 'src/Console/MyDocProcApp/MyDocProcApp.csproj'
# - name: buildConfiguration
# value: 'Debug'
# steps:
# - task: UseDotNet@2
# inputs:
# packageType: 'sdk'
# version: '8.0.x'
# # Restore the NuGet packges using Service connection for credentials
# - task: DotNetCoreCLI@2
# displayName: 'NuGet restore MyDocProcApp'
# inputs:
# command: 'restore'
# projects: $(consoleProjectPath)
# feedsToUse: 'config'
# nugetConfigPath: $(consoleNugetConfigPath)
# externalFeedCredentials: 'TelerikFeed'
# # Build the project
# - task: DotNetCoreCLI@2
# displayName: 'Build MyDocProcApp'
# inputs:
# command: 'build'
# projects: $(consoleProjectPath)
# configuration: $(buildConfiguration)
# *************************************************************** #
# * EXAMPLE - ASP.NET AJAX (.NET Framework) * #
# * * #
# * -Update package source with pipeline secrets- * #
# *************************************************************** #
# - job: BuildWebformsApp
# pool:
# vmImage: 'windows-2022'
# variables:
# nugetConfigPath: 'src\nuget.config'
# projectPath: 'src\Ajax\MySite.sln'
# steps:
# - task: NuGetToolInstaller@1
# displayName: 'Use NuGet '
# # Step 1. Using nuget.exe, set the credentials of the 'Telerik' source in the nuget.config (using pipeline secrets)
# - task: PowerShell@2
# displayName: 'Update Package Source Credentials'
# inputs:
# targetType: 'inline'
# script: nuget sources update -Name 'Telerik' -Source 'https://nuget.telerik.com/v3/index.json' -Username '$(MY_TELERIK_EMAIL)' -Password '$(MY_TELERIK_PASSWORD)' -ConfigFile '$(nugetConfigPath)' -StorePasswordInClearText
# # Step 2. Using nuget.exe, restore the NuGet packages
# - task: PowerShell@2
# displayName: 'Restore NuGet Packages'
# inputs:
# targetType: 'inline'
# script: nuget restore '$(projectPath)' -ConfigFile '$(nugetConfigPath)'
# # Step 3. Build the project without restoring packages automatically
# - task: MSBuild@1
# displayName: 'Build AJAX Project'
# inputs:
# solution: '$(projectPath)'
# platform: Any CPU
# configuration: Release
# msbuildArguments: '/p:RestorePackages=false'
# ************************************************************* #
# * EXAMPLE 3 - BLAZOR * #
# * * #
# * -Update package source with KeyVault secrets- * #
# ************************************************************* #
# - job: BuildBlazorApp
# pool:
# vmImage: 'windows-2022'
# variables:
# nugetConfigPath: 'src\Blazor\MyBlazorApp\NuGet.Config'
# projectPath: 'src\Blazor\MyBlazorApp\MyBlazorApp.csproj'
# steps:
# - task: UseDotNet@2
# inputs:
# packageType: 'sdk'
# version: '8.0.x'
# # Step 1. Using dotnet CLI, set the credentials of the 'Telerik_Feed', defined in the nuget.config
# - task: PowerShell@2
# displayName: 'Update Package Source Credentials'
# inputs:
# targetType: 'inline'
# script: dotnet nuget update source 'Telerik_Feed' -s 'https://nuget.telerik.com/v3/index.json' -u '$(MY_TELERIK_EMAIL)' -p '$(MY_TELERIK_PASSWORD)' --store-password-in-clear-text --configfile $(nugetConfigPath)
# # Step 2. Using dotnet CLI, restore NuGet packages
# - task: PowerShell@2
# displayName: 'Restore NuGet Packages'
# inputs:
# targetType: 'inline'
# script: dotnet restore $(projectPath) --configfile $(nugetConfigPath) --runtime win-x64
# # Step 3. Build the project
# - task: DotNetCoreCLI@2
# displayName: 'Build Blazor Project'
# inputs:
# command: 'build'
# projects: $(projectPath)
# configuration: Debug
# *************************************************************** #
# * EXAMPLE 4 - UWP (WinRT) * #
# * * #
# * -Uses Service Principal for credentials- * #
# *************************************************************** #
# - job: BuildUwpApp
# pool:
# vmImage: 'windows-2022'
# variables:
# solution: 'src/Uwp/SalesDashboard.UWP.sln'
# buildPlatform: 'x64'
# buildConfiguration: 'Debug'
# appxBundle: 'Never'
# appxBuildMode: 'CI'
# appxSigningEnabled: false
# steps:
# - task: NuGetToolInstaller@1
# displayName: 'Use NuGet '
# # Restore the NuGet packges using Service connection for credentials
# - task: NuGetCommand@2
# displayName: 'NuGet restore'
# inputs:
# restoreSolution: $(solution)
# feedsToUse: config
# nugetConfigPath: src/nuget.config
# externalFeedCredentials: TelerikFeed
# - task: VSBuild@1
# inputs:
# platform: $(buildPlatform)
# solution: $(solution)
# configuration: $(buildConfiguration)
# msbuildArgs: '/p:Configuration=$(buildConfiguration /p:Platform=$(buildPlatform) /p:UapAppxPackageBuildMode=$(appxBuildMode) /p:AppxPackageSigningEnabled=$(appxSigningEnabled) /p:AppxBundle=$(appxBundle)'