Skip to content

Commit 161c02b

Browse files
committed
Merge remote-tracking branch 'origin/master' into Localization
2 parents d99de0c + ddc249f commit 161c02b

File tree

8 files changed

+129
-17
lines changed

8 files changed

+129
-17
lines changed

.azure-pipelines/build-job.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ parameters:
6464
- agent
6565
- pipelines-agent
6666

67+
- name: disableSdl
68+
type: boolean
69+
default: false
70+
71+
- name: justificationForDisablingSdl
72+
type: string
73+
default: ''
74+
6775
jobs:
6876

6977
- job: ${{ parameters.jobName }}
@@ -74,6 +82,13 @@ jobs:
7482
${{ if ne(parameters.container, '') }}:
7583
container: ${{ parameters.container }}
7684

85+
${{ if eq(parameters.disableSdl, true) }}:
86+
parameters:
87+
sdl:
88+
codeql:
89+
compiled:
90+
enabled: false
91+
justificationForDisabling: ${{ parameters.justificationForDisablingSdl}}
7792
variables:
7893
PACKAGE_TYPE: ${{ parameters.packageType }}
7994
${{ if eq(parameters.os, 'win') }}:

.azure-pipelines/build-jobs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ parameters:
5959
type: boolean
6060
default: false
6161

62+
- name: disableSdl
63+
type: boolean
64+
default: false
65+
6266
jobs:
6367
- template: /.azure-pipelines/build-job.yml@self
6468
parameters:

.azure-pipelines/pipeline.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ extends:
271271
- ${{ if parameters.macOS_x64 }}:
272272
- template: /.azure-pipelines/build-jobs.yml@self
273273
parameters:
274+
disableSdl: true
274275
jobName: build_osx
275276
displayName: macOS (x64)
276277
pool:
@@ -290,6 +291,7 @@ extends:
290291
- ${{ if parameters.macOS_arm64 }}:
291292
- template: /.azure-pipelines/build-jobs.yml@self
292293
parameters:
294+
disableSdl: true
293295
jobName: build_osx_arm64
294296
displayName: macOS (ARM64)
295297
pool:

.vsts.release.yml

Lines changed: 86 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# This Yaml Document has been converted by ESAI Yaml Pipeline Conversion Tool.
22

3+
trigger:
4+
paths:
5+
include:
6+
- release
7+
- .azure-pipelines
8+
- .vsts.release.yml
9+
310
schedules:
411
- cron: '0 6 * * 2'
512
displayName: Scheduled weekly run
@@ -88,11 +95,15 @@ extends:
8895
Write-Host "isRelease = $isRelease"
8996
Write-Host "##vso[task.setVariable variable=isRelease;isOutput=true]$isRelease"
9097
98+
$isTestRun = ($buildReason -eq 'IndividualCI' -or $buildReason -eq 'PullRequest')
99+
Write-Host "isTestRun = $isTestRun"
100+
Write-Host "##vso[task.setVariable variable=isTestRun;isOutput=true]$isTestRun"
101+
91102
$isScheduledRelease = $isRelease -and $buildReason -eq 'Schedule'
92103
Write-Host "isScheduledRelease = $isScheduledRelease"
93104
94-
if ($isRelease) {
95-
if ($isScheduledRelease) {
105+
if ($isRelease -or $isTestRun) {
106+
if ($isScheduledRelease -or $isTestRun) {
96107
$majorAndMinorVersion = "3.$($currentSprint.sprint)"
97108
$patchVersion = 0
98109
## Looking for a free patch version
@@ -116,6 +127,9 @@ extends:
116127
Write-Error "Version parameter is required for manual release." -ErrorAction Stop
117128
}
118129
}
130+
if ($isTestRun) {
131+
$agentVersion = '3.000.999'
132+
}
119133
Write-Host "agentVersion = $agentVersion"
120134
Write-Host "##vso[task.setVariable variable=agentVersion;isOutput=true]$agentVersion"
121135
@@ -137,10 +151,12 @@ extends:
137151
################################################################################
138152
displayName: Create Release Branch
139153
variables:
154+
IsTestRun: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.isTestRun'] ]
140155
IsRelease: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.isRelease'] ]
141156
ReleaseBranch: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.releaseBranch'] ]
142157
AgentVersion: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.agentVersion'] ]
143-
condition: and(succeeded(), eq(variables.IsRelease, 'True'))
158+
condition: and(succeeded(), or(eq(variables.IsRelease, 'True'), eq(variables.IsTestRun, 'True')))
159+
144160
pool:
145161
name: 1ES-ABTT-Shared-Pool
146162
image: abtt-ubuntu-2204
@@ -178,10 +194,11 @@ extends:
178194
name: 1ES-Shared-Hosted-Pool_Windows-Server-2022
179195
demands: AzurePS
180196
variables:
197+
IsTestRun: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.isTestRun'] ]
181198
IsRelease: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.isRelease'] ]
182199
ReleaseBranch: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.releaseBranch'] ]
183200
AgentVersion: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.agentVersion'] ]
184-
condition: and(succeeded(), eq(variables.IsRelease, 'True'))
201+
condition: and(succeeded(), or(eq(variables.IsRelease, 'True'), eq(variables.IsTestRun, 'True')))
185202
steps:
186203

187204
# Clean
@@ -215,20 +232,46 @@ extends:
215232
Select-AzSubscription -SubscriptionId $(SubscriptionId)
216233
$storageContext = New-AzStorageContext -StorageAccountName vstsagentpackage -UseConnectedAccount
217234
$versionDir = "$(AgentVersion)"
235+
236+
$container = "agent"
237+
$isTestContainer = "$(IsTestRun)"
238+
Write-Host "isTestContainer = $isTestContainer"
239+
240+
if ($isTestContainer -eq "True") {
241+
$container = "testagent"
242+
New-AzStorageContainer -Context $storageContext -Name $container -Permission Off
243+
}
244+
Write-Host "container = $container"
245+
218246
Get-ChildItem -LiteralPath "$(System.ArtifactsDirectory)/agent" | ForEach-Object {
219247
$target=$_
220248
Get-ChildItem -LiteralPath "$(System.ArtifactsDirectory)/agent/$target" -Include "*.zip","*.tar.gz" | ForEach-Object {
221249
$executable = $_
222-
Write-Host "Uploading $executable to BlobStorage vstsagentpackage/agent/$versionDir"
223-
Set-AzStorageBlobContent -Context $storageContext -Container agent -File "$(System.ArtifactsDirectory)/agent/$target/$executable" -Blob "$versionDir/$executable" -Force
224-
$uploadFiles.Add("/agent/$versionDir/$executable")
250+
Write-Host "Uploading $executable to BlobStorage vstsagentpackage/$container/$versionDir"
251+
Set-AzStorageBlobContent -Context $storageContext -Container $container -File "$(System.ArtifactsDirectory)/agent/$target/$executable" -Blob "$versionDir/$executable" -Force
252+
$uploadFiles.Add("/$container/$versionDir/$executable")
225253
}
226254
}
227255
Write-Host "Purge Azure CDN Cache"
228256
Clear-AzCdnEndpointContent -EndpointName vstsagentpackage -ProfileName vstsagentpackage -ResourceGroupName vstsagentpackage -ContentPath $uploadFiles
229257
Write-Host "Force Refresh Azure CDN Cache"
230258
Import-AzCdnEndpointContent -EndpointName vstsagentpackage -ProfileName vstsagentpackage -ResourceGroupName vstsagentpackage -ContentPath $uploadFiles
231259
260+
# Clean up blob container with test agent version
261+
- task: AzurePowerShell@5
262+
displayName: Delete Azure Blob container with test agent version
263+
condition: and(succeeded(), eq(variables.IsTestRun, 'True'))
264+
inputs:
265+
azurePowerShellVersion: 'LatestVersion'
266+
azureSubscription: 'azure-pipelines-agent-vstsagentpackage-oauth'
267+
scriptType: 'InlineScript'
268+
inline: |
269+
Import-Module Azure, Az.Accounts, Az.Storage -ErrorAction Ignore -PassThru
270+
Select-AzSubscription -SubscriptionId $(SubscriptionId)
271+
$storageContext = New-AzStorageContext -StorageAccountName vstsagentpackage -UseConnectedAccount
272+
$container = 'testagent'
273+
Remove-AzStorageContainer -Name $container -Context $storageContext -Force
274+
232275
# Download all agent hashes created in previous phases
233276
- task: DownloadBuildArtifacts@0
234277
displayName: Download Agent Hashes
@@ -267,6 +310,7 @@ extends:
267310
$releaseCreated = Invoke-RestMethod @releaseParams
268311
Write-Host $releaseCreated
269312
$releaseId = $releaseCreated.id
313+
Write-Host "##vso[task.setVariable variable=releaseId;isoutput=true]$releaseId"
270314
$assets = [System.IO.File]::ReadAllText("$(Build.SourcesDirectory)\assets.json").Replace("<AGENT_VERSION>","$(AgentVersion)")
271315
$assetsParams = @{
272316
Uri = "https://uploads.github.com/repos/Microsoft/azure-pipelines-agent/releases/$releaseId/assets?name=assets.json"
@@ -279,6 +323,36 @@ extends:
279323
}
280324
Invoke-RestMethod @assetsParams
281325
displayName: Create agent release on Github
326+
name: create_github_release
327+
328+
# Delete test agent release
329+
- powershell: |
330+
Write-Host "Deleting test github release."
331+
$releaseId = $(create_github_release.releaseId)
332+
333+
$releaseParams = @{
334+
Uri = "https://api.github.com/repos/Microsoft/azure-pipelines-agent/releases/$releaseId";
335+
Method = 'DELETE';
336+
Headers = @{
337+
Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("vsts:$(GithubToken)"));
338+
}
339+
ContentType = 'application/json';
340+
}
341+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
342+
$releaseDeleted = Invoke-RestMethod @releaseParams
343+
Write-Host $releaseDeleted.Id
344+
displayName: Delete test agent release from Github
345+
condition: and(succeeded(), eq(variables.IsTestRun, 'True'))
346+
347+
# Clean up test release branch
348+
- powershell: |
349+
git config --global user.email "[email protected]"
350+
git config --global user.name "azure-pipelines-bot"
351+
git status
352+
git -c credential.helper='!f() { echo "username=pat"; echo "password=$(GithubToken)"; };f' push origin --delete $(ReleaseBranch)
353+
git push --delete origin v$(AgentVersion)
354+
displayName: Clean up test release branch
355+
condition: and(succeeded(), eq(variables.IsTestRun, 'True'))
282356
283357
- stage: CreatePRs
284358
dependsOn:
@@ -295,10 +369,11 @@ extends:
295369
################################################################################
296370
displayName: Create PRs in AzureDevOps and ConfigChange
297371
variables:
372+
IsTestRun: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.isTestRun'] ]
298373
IsRelease: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.isRelease'] ]
299374
ReleaseBranch: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.releaseBranch'] ]
300375
AgentVersion: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.agentVersion'] ]
301-
condition: and(succeeded(), eq(variables.IsRelease, 'True'))
376+
condition: and(succeeded(), or(eq(variables.IsRelease, 'True'), eq(variables.IsTestRun, 'True')))
302377
steps:
303378
- checkout: self
304379

@@ -320,7 +395,7 @@ extends:
320395
cd release
321396
npm install
322397
ls
323-
node createAdoPrs.js $(AgentVersion)
398+
node createAdoPrs.js $(AgentVersion) --dryrun=$(IsTestRun)
324399
name: s_CreateAdoPrs
325400
displayName: Create PRs in AzureDevOps and ConfigChange
326401
env:
@@ -341,6 +416,7 @@ extends:
341416
- job: j_SendPRsNotifications
342417
displayName: Send Release PRs notifications
343418
variables:
419+
IsTestRun: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.isTestRun'] ]
344420
IsRelease: $[ stageDependencies.Verify_release.Set_variables.outputs['SetReleaseVariables.isRelease'] ]
345421
AdoPrId: $[ stageDependencies.CreatePRs.create_ado_prs.outputs['s_CreateAdoPrs.AdoPrId'] ]
346422
AdoPrLink: $[ stageDependencies.CreatePRs.create_ado_prs.outputs['s_CreateAdoPrs.AdoPrLink'] ]
@@ -350,6 +426,7 @@ extends:
350426
and(
351427
not(${{ parameters.disableNotifications }}),
352428
eq(variables.IsRelease, 'True'),
429+
eq(variables.IsTestRun, 'False'),
353430
not(${{ parameters.onlyGitHubRelease }})
354431
)
355432
steps:

release/createAdoPrs.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ async function openPR(repo, project, sourceBranch, targetBranch, commitMessage,
8585

8686
if (!fs.existsSync(repoPath)) {
8787
const gitUrl = `https://${process.env.PAT}@${orgUrl}/${project}/_git/${repo}`;
88-
util.execInForeground(`${GIT} clone --depth 1 ${gitUrl} ${repoPath}`, null, opt.dryrun);
88+
util.execInForeground(`${GIT} clone --depth 1 ${gitUrl} ${repoPath}`, null, opt.options.dryrun);
8989
}
9090

9191
for (const targetToCommit of targetsToCommit) {
@@ -105,12 +105,12 @@ async function openPR(repo, project, sourceBranch, targetBranch, commitMessage,
105105
}
106106

107107
for (const targetToCommit of targetsToCommit) {
108-
util.execInForeground(`${GIT} add ${targetToCommit}`, repoPath, opt.dryrun);
108+
util.execInForeground(`${GIT} add ${targetToCommit}`, repoPath, opt.options.dryrun);
109109
}
110110

111-
util.execInForeground(`${GIT} checkout -b ${sourceBranch}`, repoPath);
112-
util.execInForeground(`${GIT} commit -m "${commitMessage}"`, repoPath);
113-
util.execInForeground(`${GIT} push --force origin ${sourceBranch}`, repoPath);
111+
util.execInForeground(`${GIT} checkout -b ${sourceBranch}`, repoPath, opt.options.dryrun);
112+
util.execInForeground(`${GIT} commit -m "${commitMessage}"`, repoPath, opt.options.dryrun);
113+
util.execInForeground(`${GIT} push --force origin ${sourceBranch}`, repoPath, opt.options.dryrun);
114114

115115
const prefix = 'refs/heads/';
116116

@@ -129,6 +129,8 @@ async function openPR(repo, project, sourceBranch, targetBranch, commitMessage,
129129

130130
if (PR) {
131131
console.log('PR already exists');
132+
} else if (opt.options.dryrun) {
133+
return [-1, 'test']; // return without creating PR for test runs
132134
} else {
133135
console.log('PR does not exist; creating PR');
134136
PR = await gitApi.createPullRequest(pullRequest, repo, project);
@@ -167,8 +169,8 @@ async function main() {
167169
util.verifyMinimumNodeVersion();
168170
util.verifyMinimumGitVersion();
169171
createIntegrationFiles(agentVersion);
170-
util.execInForeground(`${GIT} config --global user.email "${process.env.USEREMAIL}"`, null, opt.dryrun);
171-
util.execInForeground(`${GIT} config --global user.name "${process.env.USERNAME}"`, null, opt.dryrun);
172+
util.execInForeground(`${GIT} config --global user.email "${process.env.USEREMAIL}"`, null, opt.options.dryrun);
173+
util.execInForeground(`${GIT} config --global user.name "${process.env.USERNAME}"`, null, opt.options.dryrun);
172174

173175
const sprint = await getCurrentSprint();
174176

src/Agent.Listener/CommandSettings.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,18 @@ public CommandSettings(IHostContext context, string[] args, IScopedEnvironment e
7272
context.SecretMasker.AddValue(Configure.SslClientCert, WellKnownSecretAliases.ConfigureSslClientCert);
7373
context.SecretMasker.AddValue(Configure.Token, WellKnownSecretAliases.ConfigureToken);
7474
context.SecretMasker.AddValue(Configure.WindowsLogonPassword, WellKnownSecretAliases.ConfigureWindowsLogonPassword);
75+
context.SecretMasker.AddValue(Configure.TenantId, WellKnownSecretAliases.ConfigureTenantId);
76+
context.SecretMasker.AddValue(Configure.ClientId, WellKnownSecretAliases.ConfigureClientId);
77+
context.SecretMasker.AddValue(Configure.ClientSecret, WellKnownSecretAliases.ConfigureClientSecret);
7578
}
7679

7780
if (Remove != null)
7881
{
7982
context.SecretMasker.AddValue(Remove.Password, WellKnownSecretAliases.RemovePassword);
8083
context.SecretMasker.AddValue(Remove.Token, WellKnownSecretAliases.RemoveToken);
84+
context.SecretMasker.AddValue(Remove.TenantId, WellKnownSecretAliases.RemoveTenantId);
85+
context.SecretMasker.AddValue(Remove.ClientId, WellKnownSecretAliases.RemoveClientId);
86+
context.SecretMasker.AddValue(Remove.ClientSecret, WellKnownSecretAliases.RemoveClientSecret);
8187
}
8288

8389
PrintArguments();

src/Agent.Sdk/Knob/AgentKnobs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ public class AgentKnobs
582582
public static readonly Knob UseProcessHandlerV2 = new Knob(
583583
nameof(UseProcessHandlerV2),
584584
"Enables new Process handler (v2)",
585-
new RuntimeKnobSource("AGENT_USE_PROCESS_HANDLER_V2"),
585+
new PipelineFeatureSource("UseProcessHandlerV2"),
586586
new BuiltInDefaultKnobSource("false"));
587587

588588
public static readonly Knob DisableDrainQueuesAfterTask = new Knob(

src/Agent.Sdk/Util/WellKnownSecretAliases.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@ public static class WellKnownSecretAliases
1111
public static readonly string ConfigureSslClientCert = "Configure.SslClientCert";
1212
public static readonly string ConfigureToken = "Configure.Token";
1313
public static readonly string ConfigureWindowsLogonPassword = "Configure.WindowsLogonPassword";
14+
public static readonly string ConfigureClientId = "Configure.ClientId";
15+
public static readonly string ConfigureClientSecret = "Configure.ClientSecret";
16+
public static readonly string ConfigureTenantId = "Configure.TenantId";
1417
public static readonly string RemovePassword = "Remove.Password";
1518
public static readonly string RemoveToken = "Remove.Token";
19+
public static readonly string RemoveClientId = "Remove.ClientId";
20+
public static readonly string RemoveClientSecret = "Remove.ClientSecret";
21+
public static readonly string RemoveTenantId = "Remove.TenantId";
1622

1723
// Other known origins for secrets
1824
public static readonly string GitSourceProviderAuthHeader = "GitSourceProvider.AuthHeader";

0 commit comments

Comments
 (0)