-
Notifications
You must be signed in to change notification settings - Fork 860
Surface build output on failure for Docker, Podman, and dotnet publish #16093
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Aspire.Hosting.Publishing; | ||
|
|
||
| /// <summary> | ||
| /// Exception thrown when a container image build or dotnet publish operation fails. | ||
| /// </summary> | ||
| internal sealed class ProcessFailedException : Exception | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Since build image calls flow through pipeline steps (e.g. Consider either making |
||
| { | ||
| /// <summary> | ||
| /// Initializes a new instance of <see cref="ProcessFailedException"/>. | ||
| /// </summary> | ||
| /// <param name="message">A summary of the failure (e.g., "Docker build failed with exit code 1.").</param> | ||
| /// <param name="exitCode">The process exit code.</param> | ||
| /// <param name="buildOutput">The captured stdout/stderr lines from the build process.</param> | ||
| public ProcessFailedException(string message, int exitCode, IReadOnlyList<string> buildOutput) | ||
| : base(message) | ||
| { | ||
| ExitCode = exitCode; | ||
| BuildOutput = buildOutput; | ||
| } | ||
davidfowl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /// <summary> | ||
| /// The process exit code. | ||
| /// </summary> | ||
| public int ExitCode { get; } | ||
|
|
||
| /// <summary> | ||
| /// The captured stdout/stderr lines from the build process. | ||
| /// </summary> | ||
| public IReadOnlyList<string> BuildOutput { get; } | ||
|
|
||
| /// <inheritdoc/> | ||
| public override string Message => BuildOutput.Count > 0 | ||
| ? $"{base.Message}{Environment.NewLine}{GetFormattedOutput()}" | ||
| : base.Message; | ||
|
|
||
| /// <summary> | ||
| /// Returns the last <paramref name="maxLines"/> lines of build output formatted for display. | ||
| /// </summary> | ||
| public string GetFormattedOutput(int maxLines = 50) | ||
| { | ||
| if (BuildOutput.Count == 0) | ||
| { | ||
| return string.Empty; | ||
| } | ||
|
|
||
| IEnumerable<string> lines = BuildOutput.Count > maxLines | ||
| ? BuildOutput.Skip(BuildOutput.Count - maxLines) | ||
| : BuildOutput; | ||
|
Comment on lines
+49
to
+51
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the number of lines is truncated then should that be included in the message? e.g. |
||
|
|
||
| return string.Join(Environment.NewLine, lines); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.