Skip to content

Extract HttpClient utilities from PR 30293 and add to public API #30358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 33 additions & 15 deletions eng/common/tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -483,23 +483,41 @@ function MSBuild-Core {
function RunBuildTool {
export ARCADE_BUILD_TOOL_COMMAND="$_InitializeBuildTool $@"

"$_InitializeBuildTool" "$@" || {
local exit_code=$?
# We should not Write-PipelineTaskError here because that message shows up in the build summary
# The build already logged an error, that's the reason it failed. Producing an error here only adds noise.
echo "Build failed with exit code $exit_code. Check errors above."

# When running on Azure Pipelines, override the returned exit code to avoid double logging.
# Skip this when the build is a child of the VMR build.
if [[ "$ci" == true && -n ${SYSTEM_TEAMPROJECT:-} && "$from_vmr" != true ]]; then
Write-PipelineSetResult -result "Failed" -message "msbuild execution failed."
# Exiting with an exit code causes the azure pipelines task to log yet another "noise" error
# The above Write-PipelineSetResult will cause the task to be marked as failure without adding yet another error
ExitWithExitCode 0
local max_retries=5
local retry_count=0
local exit_code=0

while [[ $retry_count -lt $max_retries ]]; do
if "$_InitializeBuildTool" "$@"; then
# Command succeeded, break out of retry loop
return 0
else
ExitWithExitCode $exit_code
exit_code=$?
retry_count=$((retry_count + 1))

if [[ $retry_count -lt $max_retries ]]; then
echo "Build attempt $retry_count failed with exit code $exit_code. Retrying in 5 seconds... (attempt $retry_count of $max_retries)"
sleep 5
else
echo "Build failed after $max_retries attempts with exit code $exit_code. Check errors above."
fi
fi
}
done

# All retries exhausted, handle the failure
# We should not Write-PipelineTaskError here because that message shows up in the build summary
# The build already logged an error, that's the reason it failed. Producing an error here only adds noise.

# When running on Azure Pipelines, override the returned exit code to avoid double logging.
# Skip this when the build is a child of the VMR build.
if [[ "$ci" == true && -n ${SYSTEM_TEAMPROJECT:-} && "$from_vmr" != true ]]; then
Write-PipelineSetResult -result "Failed" -message "msbuild execution failed."
# Exiting with an exit code causes the azure pipelines task to log yet another "noise" error
# The above Write-PipelineSetResult will cause the task to be marked as failure without adding yet another error
ExitWithExitCode 0
else
ExitWithExitCode $exit_code
fi
}

RunBuildTool "$_InitializeBuildToolCommand" /m /nologo /clp:Summary /v:$verbosity /nr:$node_reuse $warnaserror_switch /p:TreatWarningsAsErrors=$warn_as_error /p:ContinuousIntegrationBuild=$ci "$@"
Expand Down