Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Notify pipeline syntax/configuration errors #1557

Merged
merged 2 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion resources/github-comment-markdown.template
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ ${errorStackTrace}
<% if (!buildStatus?.equals('ABORTED') && errorGithubPrCheckApproved) {%>
<% stepsErrors = stepsErrors << errorGithubPrCheckApproved %>
<%}%>
<% if (stepsErrors?.size() != 0 && !statusSuccess) {%>
<% if (!statusSuccess) {%>
<% if (stepsErrors?.size() != 0) {%>
### Steps errors [![${stepsErrors?.size()}](https://img.shields.io/badge/${stepsErrors?.size()}%20-red)](${jobUrl}/pipeline)
<details><summary>Expand to view the steps failures</summary>
<p>
Expand All @@ -112,4 +113,11 @@ ${description}
<%}%>
</p>
</details>
<%} else {%>
### Pipeline error [![1](https://img.shields.io/badge/1%20-red)](${env?.BUILD_URL}/console)
<p>
This error is likely related to the pipeline itself. Please go to the traditional console output <a href=\"${env?.BUILD_URL}/console\">here</a>"
You will see the error (either a wrong syntax or configuration)
</p>
<%}%>
<%}%>
19 changes: 19 additions & 0 deletions src/test/groovy/NotificationManagerStepTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,25 @@ class NotificationManagerStepTests extends ApmBasePipelineTest {
assertJobStatusSuccess()
}

@Test
void test_notify_pr_with_failure_and_no_failed_steps() throws Exception {
script.notifyPR(
build: readJSON(file: "build-info.json"),
buildStatus: "FAILURE",
changeSet: readJSON(file: "changeSet-info.json"),
statsUrl: "https://ecs.example.com/app/kibana",
stepsErrors: [],
testsErrors: [],
testsSummary: readJSON(file: "tests-summary.json"),
statusSuccess: false
)
printCallStack()
assertTrue(assertMethodCallContainsPattern('githubPrComment', 'Build Failed'))
assertTrue(assertMethodCallContainsPattern('githubPrComment', 'Pipeline error'))
assertTrue(assertMethodCallContainsPattern('githubPrComment', 'go to the traditional console output'))
assertJobStatusSuccess()
}

@Test
void test_notify_pr_with_unstable() throws Exception {
script.notifyPR(
Expand Down