diff options
author | dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> | 2019-02-12 04:06:11 -0500 |
---|---|---|
committer | Stephen Toub <stoub@microsoft.com> | 2019-02-12 04:06:11 -0500 |
commit | 37d3388d394a305151901720e13a7bd45eb8ca90 (patch) | |
tree | 8b3f0e930dca241e224bc4c283a268b21f3e045c /eng/common | |
parent | f0770609f8cdbeba019b35af48b70840f33bd479 (diff) | |
download | coreclr-37d3388d394a305151901720e13a7bd45eb8ca90.tar.gz coreclr-37d3388d394a305151901720e13a7bd45eb8ca90.tar.bz2 coreclr-37d3388d394a305151901720e13a7bd45eb8ca90.zip |
Update dependencies from https://github.com/dotnet/arcade build 20190208.1 (#22506)
This change updates the following dependencies
- Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.19108.1
- Microsoft.DotNet.Helix.Sdk - 2.0.0-beta.19108.1
Diffstat (limited to 'eng/common')
-rw-r--r-- | eng/common/PublishBuildAssets.cmd | 3 | ||||
-rw-r--r-- | eng/common/PublishToPackageFeed.proj | 25 | ||||
-rw-r--r-- | eng/common/darc-init.ps1 | 2 | ||||
-rw-r--r-- | eng/common/internal/Directory.Build.props | 4 | ||||
-rw-r--r-- | eng/common/internal/Directory.Build.targets | 3 | ||||
-rw-r--r-- | eng/common/internal/Tools.csproj | 19 | ||||
-rw-r--r-- | eng/common/sdk-task.ps1 | 73 | ||||
-rw-r--r-- | eng/common/templates/job/publish-build-assets.yml | 13 | ||||
-rw-r--r-- | eng/common/templates/phases/publish-build-assets.yml | 13 | ||||
-rw-r--r-- | eng/common/templates/steps/telemetry-end.yml | 87 | ||||
-rw-r--r-- | eng/common/templates/steps/telemetry-start.yml | 161 | ||||
-rw-r--r-- | eng/common/tools.ps1 | 12 | ||||
-rw-r--r-- | eng/common/tools.sh | 7 |
13 files changed, 303 insertions, 119 deletions
diff --git a/eng/common/PublishBuildAssets.cmd b/eng/common/PublishBuildAssets.cmd deleted file mode 100644 index 3c6e4ff829..0000000000 --- a/eng/common/PublishBuildAssets.cmd +++ /dev/null @@ -1,3 +0,0 @@ -@echo off -powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0sdk-task.ps1""" -msbuildEngine dotnet -restore -projects PublishBuildAssets.proj -ci %*" -exit /b %ErrorLevel% diff --git a/eng/common/PublishToPackageFeed.proj b/eng/common/PublishToPackageFeed.proj index 7dc478d981..8149e3fb6a 100644 --- a/eng/common/PublishToPackageFeed.proj +++ b/eng/common/PublishToPackageFeed.proj @@ -10,25 +10,38 @@ <TargetFramework>netcoreapp2.1</TargetFramework> </PropertyGroup> - <Import Project="$(MSBuildThisFileDirectory)MicrosoftDotNetBuildTasksFeedVersion.props" /> + <Import Project="$(MSBuildThisFileDirectory)DefaultVersions.props" Condition="Exists('$(MSBuildThisFileDirectory)DefaultVersions.props')" /> + <Import Project="$(MSBuildThisFileDirectory)Versions.props" Condition="Exists('$(MSBuildThisFileDirectory)Versions.props')" /> + <Import Project="$(NuGetPackageRoot)microsoft.dotnet.build.tasks.feed\$(MicrosoftDotNetBuildTasksFeedVersion)\build\Microsoft.DotNet.Build.Tasks.Feed.targets" /> <Target Name="PublishToFeed"> <Error Condition="'$(TargetStaticFeed)' == ''" Text="TargetStaticFeed: Target feed for publishing assets wasn't provided." /> <Error Condition="'$(AccountKeyToStaticFeed)' == ''" Text="AccountKeyToStaticFeed: Account key for target feed wasn't provided." /> - <Error Condition="'$(FullPathAssetManifest)' == ''" Text="Full path to asset manifest wasn't provided." /> - <Error Condition="'$(FullPathBlobBasePath)' == '' AND '$(FullPathPackageBasePath)' == ''" Text="A valid full path to BlobBasePath of PackageBasePath is required." /> + <Error Condition="'$(ManifestsBasePath)' == ''" Text="Full path to asset manifests directory wasn't provided." /> + <Error Condition="'$(BlobBasePath)' == '' AND '$(PackageBasePath)' == ''" Text="A valid full path to BlobBasePath of PackageBasePath is required." /> + <ItemGroup> + <!-- Include all manifests found in the manifest folder. --> + <ManifestFiles Include="$(ManifestsBasePath)*.xml" /> + </ItemGroup> + + <Error Condition="'@(ManifestFiles)' == ''" Text="No manifest file was found in the provided path: $(ManifestsBasePath)" /> + + <!-- Iterate publishing assets from each manifest file. --> <PushArtifactsInManifestToFeed ExpectedFeedUrl="$(TargetStaticFeed)" AccountKey="$(AccountKeyToStaticFeed)" + BARBuildId="$(BARBuildId)" + MaestroApiEndpoint="$(MaestroApiEndpoint)" + BuildAssetRegistryToken="$(BuildAssetRegistryToken)" Overwrite="$(OverrideAssetsWithSameName)" PassIfExistingItemIdentical="$(PassIfExistingItemIdentical)" MaxClients="$(MaxParallelUploads)" UploadTimeoutInMinutes="$(MaxUploadTimeoutInMinutes)" - AssetManifestPath="$(FullPathAssetManifest)" - BlobAssetsBasePath="$(FullPathBlobBasePath)" - PackageAssetsBasePath="$(FullPathPackageBasePath)" /> + AssetManifestPath="%(ManifestFiles.Identity)" + BlobAssetsBasePath="$(BlobBasePath)" + PackageAssetsBasePath="$(PackageBasePath)" /> </Target> <ItemGroup> diff --git a/eng/common/darc-init.ps1 b/eng/common/darc-init.ps1 index 96cad844ba..57db185df1 100644 --- a/eng/common/darc-init.ps1 +++ b/eng/common/darc-init.ps1 @@ -19,7 +19,7 @@ function InstallDarcCli ($darcVersion) { # Until we can anonymously query the BAR API for the latest arcade-services # build applied to the PROD channel, this is hardcoded. if (-not $darcVersion) { - $darcVersion = '1.1.0-beta.19057.9' + $darcVersion = '1.1.0-beta.19081.1' } $arcadeServicesSource = 'https://dotnetfeed.blob.core.windows.net/dotnet-arcade/index.json' diff --git a/eng/common/internal/Directory.Build.props b/eng/common/internal/Directory.Build.props new file mode 100644 index 0000000000..e33179ef37 --- /dev/null +++ b/eng/common/internal/Directory.Build.props @@ -0,0 +1,4 @@ +<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. --> +<Project> + <Import Project="Sdk.props" Sdk="Microsoft.DotNet.Arcade.Sdk" /> +</Project> diff --git a/eng/common/internal/Directory.Build.targets b/eng/common/internal/Directory.Build.targets new file mode 100644 index 0000000000..5d26408a98 --- /dev/null +++ b/eng/common/internal/Directory.Build.targets @@ -0,0 +1,3 @@ +<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. --> +<Project> +</Project> diff --git a/eng/common/internal/Tools.csproj b/eng/common/internal/Tools.csproj new file mode 100644 index 0000000000..1d2e218376 --- /dev/null +++ b/eng/common/internal/Tools.csproj @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. --> +<Project Sdk="Microsoft.NET.Sdk"> + <PropertyGroup> + <TargetFramework>net472</TargetFramework> + </PropertyGroup> + <ItemGroup> + <!-- Clear references, the SDK may add some depending on UsuingToolXxx settings, but we only want to restore the following --> + <PackageReference Remove="@(PackageReference)"/> + <PackageReference Include="Microsoft.DotNet.IBCMerge" Version="$(MicrosoftDotNetIBCMergeVersion)" Condition="'$(UsingToolIbcOptimization)' == 'true'" /> + <PackageReference Include="Drop.App" Version="$(DropAppVersion)" ExcludeAssets="all" Condition="'$(UsingToolVisualStudioIbcTraining)' == 'true'"/> + </ItemGroup> + <PropertyGroup> + <RestoreSources> + https://devdiv.pkgs.visualstudio.com/_packaging/8f470c7e-ac49-4afe-a6ee-cf784e438b93/nuget/v3/index.json; + https://devdiv.pkgs.visualstudio.com/_packaging/VS/nuget/v3/index.json; + </RestoreSources> + </PropertyGroup> +</Project> diff --git a/eng/common/sdk-task.ps1 b/eng/common/sdk-task.ps1 index 9ba7530122..d0eec5163e 100644 --- a/eng/common/sdk-task.ps1 +++ b/eng/common/sdk-task.ps1 @@ -1,48 +1,47 @@ [CmdletBinding(PositionalBinding=$false)] Param( - [string] $projects = "", - [string][Alias('v')]$verbosity = "minimal", + [string] $configuration = "Debug", + [string] $task, + [string] $verbosity = "minimal", [string] $msbuildEngine = $null, - [bool] $warnAsError = $true, - [switch][Alias('bl')]$binaryLog, - [switch][Alias('r')]$restore, - [switch] $ci, + [switch] $restore, [switch] $prepareMachine, [switch] $help, [Parameter(ValueFromRemainingArguments=$true)][String[]]$properties ) +$ci = $true +$binaryLog = $true +$warnAsError = $true + . $PSScriptRoot\tools.ps1 function Print-Usage() { - Write-Host "Common settings:" - Write-Host " -v[erbosity] <value> Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]" - Write-Host " -[bl|binaryLog] Output binary log (short: -bl)" - Write-Host " -help Print help and exit" - Write-Host "" + Write-Host "Common settings:" + Write-Host " -task <value> Name of Arcade task (name of a project in SdkTasks directory of the Arcade SDK package)" + Write-Host " -restore Restore dependencies" + Write-Host " -verbosity <value> Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]" + Write-Host " -help Print help and exit" + Write-Host "" - Write-Host "Advanced settings:" - Write-Host " -restore Restore dependencies (short: -r)" - Write-Host " -projects <value> Semi-colon delimited list of sln/proj's from the Arcade sdk to build. Globbing is supported (*.sln)" - Write-Host " -ci Set when running on CI server" - Write-Host " -prepareMachine Prepare machine for CI run" - Write-Host " -msbuildEngine <value> Msbuild engine to use to run build ('dotnet', 'vs', or unspecified)." - Write-Host "" - Write-Host "Command line arguments not listed above are passed thru to msbuild." - Write-Host "The above arguments can be shortened as much as to be unambiguous (e.g. -co for configuration, -t for test, etc.)." + Write-Host "Advanced settings:" + Write-Host " -prepareMachine Prepare machine for CI run" + Write-Host " -msbuildEngine <value> Msbuild engine to use to run build ('dotnet', 'vs', or unspecified)." + Write-Host "" + Write-Host "Command line arguments not listed above are passed thru to msbuild." } -function Build { - $toolsetBuildProj = InitializeToolset +function Build([string]$target) { + $logSuffix = if ($target -eq "Execute") { "" } else { ".$target" } + $log = Join-Path $LogDir "$task$logSuffix.binlog" + $outputPath = Join-Path $ToolsetDir "$task\\" - $toolsetBuildProj = Join-Path (Split-Path $toolsetBuildProj -Parent) "SdkTasks\SdkTask.proj" - $bl = if ($binaryLog) { "/bl:" + (Join-Path $LogDir "SdkTask.binlog") } else { "" } - MSBuild $toolsetBuildProj ` - $bl ` - /p:Projects=$projects ` - /p:Restore=$restore ` + MSBuild $taskProject ` + /bl:$log ` + /t:$target ` + /p:Configuration=$configuration ` /p:RepoRoot=$RepoRoot ` - /p:ContinuousIntegrationBuild=$ci ` + /p:BaseIntermediateOutputPath=$outputPath ` @properties } @@ -52,17 +51,23 @@ try { exit 0 } - if ($projects -eq "") { - Write-Error "Missing required parameter '-projects <value>'" + if ($task -eq "") { + Write-Host "Missing required parameter '-task <value>'" -ForegroundColor Red Print-Usage ExitWithExitCode 1 } - if ($ci) { - $binaryLog = $true + $taskProject = GetSdkTaskProject $task + if (!(Test-Path $taskProject)) { + Write-Host "Unknown task: $task" -ForegroundColor Red + ExitWithExitCode 1 + } + + if ($restore) { + Build "Restore" } - Build + Build "Execute" } catch { Write-Host $_ diff --git a/eng/common/templates/job/publish-build-assets.yml b/eng/common/templates/job/publish-build-assets.yml index c094658fef..d6d8697cbd 100644 --- a/eng/common/templates/job/publish-build-assets.yml +++ b/eng/common/templates/job/publish-build-assets.yml @@ -44,12 +44,15 @@ jobs: downloadPath: '$(Build.StagingDirectory)/Download' condition: ${{ parameters.condition }} continueOnError: ${{ parameters.continueOnError }} - - script: eng\common\publishbuildassets.cmd - /p:ManifestsPath='$(Build.StagingDirectory)/Download/AssetManifests' - /p:BuildAssetRegistryToken=$(MaestroAccessToken) - /p:MaestroApiEndpoint=https://maestro-prod.westus2.cloudapp.azure.com - /p:Configuration=$(_BuildConfig) + - task: PowerShell@2 displayName: Publish Build Assets + inputs: + filePath: eng\common\sdk-task.ps1 + arguments: -task PublishBuildAssets -restore -msbuildEngine dotnet + /p:ManifestsPath='$(Build.StagingDirectory)/Download/AssetManifests' + /p:BuildAssetRegistryToken=$(MaestroAccessToken) + /p:MaestroApiEndpoint=https://maestro-prod.westus2.cloudapp.azure.com + /p:Configuration=$(_BuildConfig) condition: ${{ parameters.condition }} continueOnError: ${{ parameters.continueOnError }} - ${{ if eq(parameters.enablePublishBuildArtifacts, 'true') }}: diff --git a/eng/common/templates/phases/publish-build-assets.yml b/eng/common/templates/phases/publish-build-assets.yml index 85fabe62b9..211967deba 100644 --- a/eng/common/templates/phases/publish-build-assets.yml +++ b/eng/common/templates/phases/publish-build-assets.yml @@ -28,12 +28,15 @@ phases: SecretsFilter: 'MaestroAccessToken' condition: ${{ parameters.condition }} continueOnError: ${{ parameters.continueOnError }} - - script: eng\common\publishbuildassets.cmd - /p:ManifestsPath='$(Build.StagingDirectory)/Download/AssetManifests' - /p:BuildAssetRegistryToken=$(MaestroAccessToken) - /p:MaestroApiEndpoint=https://maestro-prod.westus2.cloudapp.azure.com - /p:Configuration=$(_BuildConfig) + - task: PowerShell@2 displayName: Publish Build Assets + inputs: + filePath: eng\common\sdk-task.ps1 + arguments: -task PublishBuildAssets -restore -msbuildEngine dotnet + /p:ManifestsPath='$(Build.StagingDirectory)/Download/AssetManifests' + /p:BuildAssetRegistryToken=$(MaestroAccessToken) + /p:MaestroApiEndpoint=https://maestro-prod.westus2.cloudapp.azure.com + /p:Configuration=$(_BuildConfig) condition: ${{ parameters.condition }} continueOnError: ${{ parameters.continueOnError }} - task: PublishBuildArtifacts@1 diff --git a/eng/common/templates/steps/telemetry-end.yml b/eng/common/templates/steps/telemetry-end.yml index 9b61481e7e..fadc04ca1b 100644 --- a/eng/common/templates/steps/telemetry-end.yml +++ b/eng/common/templates/steps/telemetry-end.yml @@ -1,3 +1,7 @@ +parameters: + maxRetries: 5 + retryDelay: 10 # in seconds + steps: - bash: | if [ "$AGENT_JOBSTATUS" = "Succeeded" ] || [ "$AGENT_JOBSTATUS" = "PartiallySucceeded" ]; then @@ -7,27 +11,41 @@ steps: fi warningCount=0 - # create a temporary file for curl output - res=`mktemp` - - curlResult=` - curl --verbose --output $res --write-out "%{http_code}"\ - -H 'Content-Type: application/json' \ - -H "X-Helix-Job-Token: $Helix_JobToken" \ - -H 'Content-Length: 0' \ - -X POST -G "https://helix.dot.net/api/2018-03-14/telemetry/job/build/$Helix_WorkItemId/finish" \ - --data-urlencode "errorCount=$errorCount" \ - --data-urlencode "warningCount=$warningCount"` - curlStatus=$? - - if [ $curlStatus -eq 0 ]; then - if [ $curlResult -gt 299 ] || [ $curlResult -lt 200 ]; then - curlStatus=$curlResult + curlStatus=1 + retryCount=0 + # retry loop to harden against spotty telemetry connections + # we don't retry successes and 4xx client errors + until [[ $curlStatus -eq 0 || ( $curlStatus -ge 400 && $curlStatus -le 499 ) || $retryCount -ge $MaxRetries ]] + do + if [ $retryCount -gt 0 ]; then + echo "Failed to send telemetry to Helix; waiting $RetryDelay seconds before retrying..." + sleep $RetryDelay fi - fi + + # create a temporary file for curl output + res=`mktemp` + + curlResult=` + curl --verbose --output $res --write-out "%{http_code}"\ + -H 'Content-Type: application/json' \ + -H "X-Helix-Job-Token: $Helix_JobToken" \ + -H 'Content-Length: 0' \ + -X POST -G "https://helix.dot.net/api/2018-03-14/telemetry/job/build/$Helix_WorkItemId/finish" \ + --data-urlencode "errorCount=$errorCount" \ + --data-urlencode "warningCount=$warningCount"` + curlStatus=$? + + if [ $curlStatus -eq 0 ]; then + if [ $curlResult -gt 299 ] || [ $curlResult -lt 200 ]; then + curlStatus=$curlResult + fi + fi + + let retryCount++ + done if [ $curlStatus -ne 0 ]; then - echo "Failed to Send Build Finish information" + echo "Failed to Send Build Finish information after $retryCount retries" vstsLogOutput="vso[task.logissue type=error;sourcepath=templates/steps/telemetry-end.yml;code=1;]Failed to Send Build Finish information: $curlStatus" echo "##$vstsLogOutput" exit 1 @@ -37,6 +55,8 @@ steps: # defined via VSTS variables in start-job.sh Helix_JobToken: $(Helix_JobToken) Helix_WorkItemId: $(Helix_WorkItemId) + MaxRetries: ${{ parameters.maxRetries }} + RetryDelay: ${{ parameters.retryDelay }} condition: and(always(), ne(variables['Agent.Os'], 'Windows_NT')) - powershell: | if (($env:Agent_JobStatus -eq 'Succeeded') -or ($env:Agent_JobStatus -eq 'PartiallySucceeded')) { @@ -46,13 +66,30 @@ steps: } $WarningCount = 0 - try { - Invoke-RestMethod -Uri "https://helix.dot.net/api/2018-03-14/telemetry/job/build/$env:Helix_WorkItemId/finish?errorCount=$ErrorCount&warningCount=$WarningCount" -Method Post -ContentType "application/json" -Body "" ` - -Headers @{ 'X-Helix-Job-Token'=$env:Helix_JobToken } + # Basic retry loop to harden against server flakiness + $retryCount = 0 + while ($retryCount -lt $env:MaxRetries) { + try { + Invoke-RestMethod -Uri "https://helix.dot.net/api/2018-03-14/telemetry/job/build/$env:Helix_WorkItemId/finish?errorCount=$ErrorCount&warningCount=$WarningCount" -Method Post -ContentType "application/json" -Body "" ` + -Headers @{ 'X-Helix-Job-Token'=$env:Helix_JobToken } + break + } + catch { + $statusCode = $_.Exception.Response.StatusCode.value__ + if ($statusCode -ge 400 -and $statusCode -le 499) { + Write-Host "##vso[task.logissue]error Failed to send telemetry to Helix (status code $statusCode); not retrying (4xx client error)" + Write-Host "##vso[task.logissue]error ", $_.Exception.GetType().FullName, $_.Exception.Message + exit 1 + } + Write-Host "Failed to send telemetry to Helix (status code $statusCode); waiting $env:RetryDelay seconds before retrying..." + $retryCount++ + sleep $env:RetryDelay + continue + } } - catch { - Write-Error $_ - Write-Error $_.Exception + + if ($retryCount -ge $env:MaxRetries) { + Write-Host "##vso[task.logissue]error Failed to send telemetry to Helix after $retryCount retries." exit 1 } displayName: Send Windows Build End Telemetry @@ -60,4 +97,6 @@ steps: # defined via VSTS variables in start-job.ps1 Helix_JobToken: $(Helix_JobToken) Helix_WorkItemId: $(Helix_WorkItemId) + MaxRetries: ${{ parameters.maxRetries }} + RetryDelay: ${{ parameters.retryDelay }} condition: and(always(),eq(variables['Agent.Os'], 'Windows_NT')) diff --git a/eng/common/templates/steps/telemetry-start.yml b/eng/common/templates/steps/telemetry-start.yml index 79c128c5de..32c01ef0b5 100644 --- a/eng/common/templates/steps/telemetry-start.yml +++ b/eng/common/templates/steps/telemetry-start.yml @@ -3,6 +3,8 @@ parameters: helixType: 'undefined_defaulted_in_telemetry.yml' buildConfig: '' runAsPublic: false + maxRetries: 5 + retryDelay: 10 # in seconds steps: - ${{ if and(eq(parameters.runAsPublic, 'false'), not(eq(variables['System.TeamProject'], 'public'))) }}: @@ -30,7 +32,7 @@ steps: } } JobListStuff - + cat $jobInfo # create a temporary file for curl output @@ -38,30 +40,44 @@ steps: accessTokenParameter="?access_token=$HelixApiAccessToken" - curlResult=` - cat $jobInfo |\ - curl --trace - --verbose --output $res --write-out "%{http_code}" \ - -H 'Content-Type: application/json' \ - -X POST "https://helix.dot.net/api/2018-03-14/telemetry/job$accessTokenParameter" -d @-` - curlStatus=$? + curlStatus=1 + retryCount=0 + # retry loop to harden against spotty telemetry connections + # we don't retry successes and 4xx client errors + until [[ $curlStatus -eq 0 || ( $curlStatus -ge 400 && $curlStatus -le 499 ) || $retryCount -ge $MaxRetries ]] + do + if [ $retryCount -gt 0 ]; then + echo "Failed to send telemetry to Helix; waiting $RetryDelay seconds before retrying..." + sleep $RetryDelay + fi + + curlResult=` + cat $jobInfo |\ + curl --trace - --verbose --output $res --write-out "%{http_code}" \ + -H 'Content-Type: application/json' \ + -X POST "https://helix.dot.net/api/2018-03-14/telemetry/job$accessTokenParameter" -d @-` + curlStatus=$? - if [ $curlStatus -eq 0 ]; then - if [ $curlResult -gt 299 ] || [ $curlResult -lt 200 ]; then - curlStatus=$curlResult + if [ $curlStatus -eq 0 ]; then + if [ $curlResult -gt 299 ] || [ $curlResult -lt 200 ]; then + curlStatus=$curlResult + fi fi - fi + + let retryCount++ + done curlResult=`cat $res` - + # validate status of curl command if [ $curlStatus -ne 0 ]; then - echo "Failed To Send Job Start information" + echo "Failed To Send Job Start information after $retryCount retries" # We have to append the ## vso prefix or vso will pick up the command when it dumps the inline script into the shell vstsLogOutput="vso[task.logissue type=error;sourcepath=telemetry/start-job.sh;code=1;]Failed to Send Job Start information: $curlStatus" echo "##$vstsLogOutput" exit 1 fi - + # Set the Helix_JobToken variable export Helix_JobToken=`echo $curlResult | xargs echo` # Strip Quotes echo "##vso[task.setvariable variable=Helix_JobToken;issecret=true;]$Helix_JobToken" @@ -75,29 +91,44 @@ steps: Attempt: 1 OperatingSystem: $(Agent.Os) Configuration: ${{ parameters.buildConfig }} + MaxRetries: ${{ parameters.maxRetries }} + RetryDelay: ${{ parameters.retryDelay }} condition: and(always(), ne(variables['Agent.Os'], 'Windows_NT')) - bash: | - res=`mktemp` - curlResult=` - curl --verbose --output $res --write-out "%{http_code}"\ - -H 'Content-Type: application/json' \ - -H "X-Helix-Job-Token: $Helix_JobToken" \ - -H 'Content-Length: 0' \ - -X POST -G "https://helix.dot.net/api/2018-03-14/telemetry/job/build" \ - --data-urlencode "buildUri=$BuildUri"` - curlStatus=$? - - if [ $curlStatus -eq 0 ]; then - if [ $curlResult -gt 299 ] || [ $curlResult -lt 200 ]; then - curlStatus=$curlResult + curlStatus=1 + retryCount=0 + # retry loop to harden against spotty telemetry connections + # we don't retry successes and 4xx client errors + until [[ $curlStatus -eq 0 || ( $curlStatus -ge 400 && $curlStatus -le 499 ) || $retryCount -ge $MaxRetries ]] + do + if [ $retryCount -gt 0 ]; then + echo "Failed to send telemetry to Helix; waiting $RetryDelay seconds before retrying..." + sleep $RetryDelay fi - fi - curlResult=`cat $res` + res=`mktemp` + curlResult=` + curl --verbose --output $res --write-out "%{http_code}"\ + -H 'Content-Type: application/json' \ + -H "X-Helix-Job-Token: $Helix_JobToken" \ + -H 'Content-Length: 0' \ + -X POST -G "https://helix.dot.net/api/2018-03-14/telemetry/job/build" \ + --data-urlencode "buildUri=$BuildUri"` + curlStatus=$? + + if [ $curlStatus -eq 0 ]; then + if [ $curlResult -gt 299 ] || [ $curlResult -lt 200 ]; then + curlStatus=$curlResult + fi + fi + + curlResult=`cat $res` + let retryCount++ + done # validate status of curl command if [ $curlStatus -ne 0 ]; then - echo "Failed to Send Build Start information" + echo "Failed to Send Build Start information after $retryCount retries" vstsLogOutput="vso[task.logissue type=error;sourcepath=telemetry/build/start.sh;code=1;]Failed to Send Build Start information: $curlStatus" echo "##$vstsLogOutput" exit 1 @@ -109,8 +140,10 @@ steps: env: BuildUri: $(System.TaskDefinitionsUri)$(System.TeamProject)/_build/index?buildId=$(Build.BuildId)&_a=summary Helix_JobToken: $(Helix_JobToken) + MaxRetries: ${{ parameters.maxRetries }} + RetryDelay: ${{ parameters.retryDelay }} condition: and(always(), ne(variables['Agent.Os'], 'Windows_NT')) - + - powershell: | $jobInfo = [pscustomobject]@{ QueueId=$env:QueueId; @@ -120,17 +153,42 @@ steps: Attempt=$env:Attempt; Properties=[pscustomobject]@{ operatingSystem=$env:OperatingSystem; configuration=$env:Configuration }; } - + $jobInfoJson = $jobInfo | ConvertTo-Json if ($env:HelixApiAccessToken) { $accessTokenParameter="?access_token=$($env:HelixApiAccessToken)" } Write-Host "Job Info: $jobInfoJson" - $jobToken = Invoke-RestMethod -Uri "https://helix.dot.net/api/2018-03-14/telemetry/job$($accessTokenParameter)" -Method Post -ContentType "application/json" -Body $jobInfoJson + + # Basic retry loop to harden against server flakiness + $retryCount = 0 + while ($retryCount -lt $env:MaxRetries) { + try { + $jobToken = Invoke-RestMethod -Uri "https://helix.dot.net/api/2018-03-14/telemetry/job$($accessTokenParameter)" -Method Post -ContentType "application/json" -Body $jobInfoJson + break + } + catch { + $statusCode = $_.Exception.Response.StatusCode.value__ + if ($statusCode -ge 400 -and $statusCode -le 499) { + Write-Host "##vso[task.logissue]error Failed to send telemetry to Helix (status code $statusCode); not retrying (4xx client error)" + Write-Host "##vso[task.logissue]error ", $_.Exception.GetType().FullName, $_.Exception.Message + exit 1 + } + Write-Host "Failed to send telemetry to Helix (status code $statusCode); waiting $env:RetryDelay seconds before retrying..." + $retryCount++ + sleep $env:RetryDelay + continue + } + } + + if ($retryCount -ge $env:MaxRetries) { + Write-Host "##vso[task.logissue]error Failed to send telemetry to Helix after $retryCount retries." + exit 1 + } + $env:Helix_JobToken = $jobToken Write-Host "##vso[task.setvariable variable=Helix_JobToken;issecret=true;]$env:Helix_JobToken" - displayName: Send Windows Job Start Telemetry env: HelixApiAccessToken: $(HelixApiAccessToken) Source: ${{ parameters.helixSource }} @@ -140,15 +198,44 @@ steps: Attempt: 1 OperatingSystem: $(Agent.Os) Configuration: ${{ parameters.buildConfig }} + MaxRetries: ${{ parameters.maxRetries }} + RetryDelay: ${{ parameters.retryDelay }} condition: and(always(), eq(variables['Agent.Os'], 'Windows_NT')) + displayName: Send Windows Job Start Telemetry - powershell: | - $workItemId = Invoke-RestMethod -Uri "https://helix.dot.net/api/2018-03-14/telemetry/job/build?buildUri=$([Net.WebUtility]::UrlEncode($env:BuildUri))" -Method Post -ContentType "application/json" -Body "" ` - -Headers @{ 'X-Helix-Job-Token'=$env:Helix_JobToken } - + # Basic retry loop to harden against server flakiness + $retryCount = 0 + while ($retryCount -lt $env:MaxRetries) { + try { + $workItemId = Invoke-RestMethod -Uri "https://helix.dot.net/api/2018-03-14/telemetry/job/build?buildUri=$([Net.WebUtility]::UrlEncode($env:BuildUri))" -Method Post -ContentType "application/json" -Body "" ` + -Headers @{ 'X-Helix-Job-Token'=$env:Helix_JobToken } + break + } + catch { + $statusCode = $_.Exception.Response.StatusCode.value__ + if ($statusCode -ge 400 -and $statusCode -le 499) { + Write-Host "##vso[task.logissue]error Failed to send telemetry to Helix (status code $statusCode); not retrying (4xx client error)" + Write-Host "##vso[task.logissue]error ", $_.Exception.GetType().FullName, $_.Exception.Message + exit 1 + } + Write-Host "Failed to send telemetry to Helix (status code $statusCode); waiting $env:RetryDelay seconds before retrying..." + $retryCount++ + sleep $env:RetryDelay + continue + } + } + + if ($retryCount -ge $env:MaxRetries) { + Write-Host "##vso[task.logissue]error Failed to send telemetry to Helix after $retryCount retries." + exit 1 + } + $env:Helix_WorkItemId = $workItemId Write-Host "##vso[task.setvariable variable=Helix_WorkItemId]$env:Helix_WorkItemId" displayName: Send Windows Build Start Telemetry env: BuildUri: $(System.TaskDefinitionsUri)$(System.TeamProject)/_build/index?buildId=$(Build.BuildId)&_a=summary Helix_JobToken: $(Helix_JobToken) + MaxRetries: ${{ parameters.maxRetries }} + RetryDelay: ${{ parameters.retryDelay }} condition: and(always(), eq(variables['Agent.Os'], 'Windows_NT')) diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1 index 4204dc14f8..c0a559589f 100644 --- a/eng/common/tools.ps1 +++ b/eng/common/tools.ps1 @@ -161,9 +161,10 @@ function GetDotNetInstallScript([string] $dotnetRoot) { return $installScript } -function InstallDotNetSdk([string] $dotnetRoot, [string] $version) { +function InstallDotNetSdk([string] $dotnetRoot, [string] $version, [string] $architecture = "") { $installScript = GetDotNetInstallScript $dotnetRoot - & $installScript -Version $version -InstallDir $dotnetRoot + $archArg = if ($architecture) { $architecture } else { "<auto>" } + & $installScript -Version $version -InstallDir $dotnetRoot -Architecture $archArg if ($lastExitCode -ne 0) { Write-Host "Failed to install dotnet cli (exit code '$lastExitCode')." -ForegroundColor Red ExitWithExitCode $lastExitCode @@ -376,6 +377,11 @@ function GetNuGetPackageCachePath() { return $env:NUGET_PACKAGES } +# Returns a full path to an Arcade SDK task project file. +function GetSdkTaskProject([string]$taskName) { + return Join-Path (Split-Path (InitializeToolset) -Parent) "SdkTasks\$taskName.proj" +} + function InitializeToolset() { if (Test-Path variable:global:_ToolsetBuildProj) { return $global:_ToolsetBuildProj @@ -394,7 +400,7 @@ function InitializeToolset() { } if (-not $restore) { - Write-Host "Toolset version $toolsetVersion has not been restored." + Write-Host "Toolset version $toolsetVersion has not been restored." -ForegroundColor Red ExitWithExitCode 1 } diff --git a/eng/common/tools.sh b/eng/common/tools.sh index 8a253bef51..115a56a827 100644 --- a/eng/common/tools.sh +++ b/eng/common/tools.sh @@ -153,7 +153,12 @@ function InstallDotNetSdk { GetDotNetInstallScript "$root" local install_script=$_GetDotNetInstallScript - bash "$install_script" --version $version --install-dir "$root" || { + local arch_arg="" + if [[ $# == 3 ]]; then + arch_arg="--architecture $3" + fi + + bash "$install_script" --version $version --install-dir "$root" $arch_arg || { local exit_code=$? echo "Failed to install dotnet SDK (exit code '$exit_code')." >&2 ExitWithExitCode $exit_code |