mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-07-28 23:58:19 +00:00
fix: add comment creation for pre-workflow hook failures
- Remove unused formatPreWorkflowHookError helper function - Use inline markdown code blocks for error formatting - Add comment creation in both RunAutoplanCommand and RunCommentCommand - Fixes compilation error in PR #5659
This commit is contained in:
@@ -214,6 +214,12 @@ func (c *DefaultCommandRunner) RunAutoplanCommand(baseRepo models.Repo, headRepo
|
||||
if c.FailOnPreWorkflowHookError {
|
||||
ctx.Log.Err("'fail-on-pre-workflow-hook-error' set, so not running %s command.", command.Plan)
|
||||
|
||||
// Create comment on pull request about the pre-workflow hook failure
|
||||
errMsg := fmt.Sprintf("```\nError: Pre-workflow hook failed: %s\n```", err.Error())
|
||||
if err := c.VCSClient.CreateComment(ctx.Log, ctx.Pull.BaseRepo, ctx.Pull.Num, errMsg, ""); err != nil {
|
||||
ctx.Log.Warn("Unable to create comment about pre-workflow hook failure: %s", err)
|
||||
}
|
||||
|
||||
// Update the plan or apply commit status to failed
|
||||
switch cmd.Name {
|
||||
case command.Plan:
|
||||
@@ -378,6 +384,12 @@ func (c *DefaultCommandRunner) RunCommentCommand(baseRepo models.Repo, maybeHead
|
||||
if c.FailOnPreWorkflowHookError {
|
||||
ctx.Log.Err("'fail-on-pre-workflow-hook-error' set, so not running %s command.", cmd.Name.String())
|
||||
|
||||
// Create comment on pull request about the pre-workflow hook failure
|
||||
errMsg := fmt.Sprintf("```\nError: Pre-workflow hook failed: %s\n```", err.Error())
|
||||
if err := c.VCSClient.CreateComment(ctx.Log, ctx.Pull.BaseRepo, ctx.Pull.Num, errMsg, ""); err != nil {
|
||||
ctx.Log.Warn("Unable to create comment about pre-workflow hook failure: %s", err)
|
||||
}
|
||||
|
||||
// Update the plan or apply commit status to failed
|
||||
switch cmd.Name {
|
||||
case command.Plan:
|
||||
@@ -566,3 +578,6 @@ func (c *DefaultCommandRunner) logPanics(baseRepo models.Repo, pullNum int, logg
|
||||
}
|
||||
|
||||
var automergeComment = `Automatically merging because all plans have been successfully applied.`
|
||||
|
||||
// formatPreWorkflowHookError formats the pre-workflow hook error for display in a comment
|
||||
|
||||
|
||||
Reference in New Issue
Block a user