Skip to content
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

Exec: take EchoOff into account when command fails #5962

Merged
merged 3 commits into from
Dec 18, 2020
Merged
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
12 changes: 9 additions & 3 deletions src/Tasks/Exec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,17 +336,23 @@ protected override bool HandleTaskExecutionErrors()
{
if (IgnoreExitCode)
{
Log.LogMessageFromResources(MessageImportance.Normal, "Exec.CommandFailedNoErrorCode", Command, ExitCode);
// Don't log when EchoOff and IgnoreExitCode.
if (!EchoOff)
{
Log.LogMessageFromResources(MessageImportance.Normal, "Exec.CommandFailedNoErrorCode", Command, ExitCode);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Is it worth preserving this "exited with code" message if we use the scrubbed command from below? It may be useful information, depending on situation--if it's an "always fails with the same code, just go with it" thing you probably don't need that; if it's a "sometimes fails so this is just best effort" it might help chase down a later failure caused by the failure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I omitted the logging because it enables the user to take action on its own based on the output ExitCode of the Exec task.
This could be custom messages, or other a fail back action.

I'm fine changing this to use the "..." placeholder.

Or we can lower the importance when EchoOff (in addition to using the "...").

@rainersigwald what do you prefer?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think as-is is ok; we'll see if anyone complains.

}
return true;
}

// Don't emit expanded form of Command when EchoOff is set.
string commandForLog = EchoOff ? "..." : Command;
if (ExitCode == NativeMethods.SE_ERR_ACCESSDENIED)
{
Log.LogErrorWithCodeFromResources("Exec.CommandFailedAccessDenied", Command, ExitCode);
Log.LogErrorWithCodeFromResources("Exec.CommandFailedAccessDenied", commandForLog, ExitCode);
}
else
{
Log.LogErrorWithCodeFromResources("Exec.CommandFailed", Command, ExitCode);
Log.LogErrorWithCodeFromResources("Exec.CommandFailed", commandForLog, ExitCode);
}
return false;
}
Expand Down