diff --git a/src/Runner.Worker/Container/ContainerHooks/ContainerHookManager.cs b/src/Runner.Worker/Container/ContainerHooks/ContainerHookManager.cs index cf4bdfa1b8c..cad6363afa5 100644 --- a/src/Runner.Worker/Container/ContainerHooks/ContainerHookManager.cs +++ b/src/Runner.Worker/Container/ContainerHooks/ContainerHookManager.cs @@ -137,6 +137,7 @@ public string GetContainerHookData() private async Task ExecuteHookScript(IExecutionContext context, HookInput input, ActionRunStage stage, string prependPath) where T : HookResponse { + bool stepFailed = false; try { ValidateHookExecutable(); @@ -167,12 +168,13 @@ private async Task ExecuteHookScript(IExecutionContext context, HookInput await handler.RunAsync(stage); if (handler.ExecutionContext.Result == TaskResult.Failed) { + stepFailed = true; throw new Exception($"The hook script at '{HookScriptPath}' running command '{input.Command}' did not execute successfully"); } var response = GetResponse(input); return response; } - catch (Exception ex) + catch (Exception ex) when (!stepFailed) { throw new Exception($"Executing the custom container implementation failed. Please contact your self hosted runner administrator.", ex); }