diff --git a/resources/github-comment-markdown.template b/resources/github-comment-markdown.template
index 283dfbca1..2f0efc40e 100644
--- a/resources/github-comment-markdown.template
+++ b/resources/github-comment-markdown.template
@@ -100,7 +100,7 @@ ${errorStackTrace}
<% description = (c?.displayDescription && c?.displayDescription != 'null') ? "
Description: ${c?.displayDescription}" : ''%>
<% duration = (c?.durationInMillis >= 0 ) ? "Took ${Math.round(c.durationInMillis/1000/60)} min ${Math.round(c.durationInMillis/1000)%60} sec" : ''%>
<% url = (c?.url && c?.url != 'null') ? ". View more details on here" : ''%>
-##### `${c?.displayName && c?.displayName != 'null' ? c?.displayName : ''}`
+##### `${c?.displayName && c?.displayName != 'null' ? c?.displayName.replaceAll('\\n', '') : ''}`
- ${duration} ${url}
${description}
diff --git a/src/test/groovy/NotificationManagerStepTests.groovy b/src/test/groovy/NotificationManagerStepTests.groovy
index 6d94892e2..4b735c0f5 100644
--- a/src/test/groovy/NotificationManagerStepTests.groovy
+++ b/src/test/groovy/NotificationManagerStepTests.groovy
@@ -278,6 +278,23 @@ class NotificationManagerStepTests extends ApmBasePipelineTest {
assertJobStatusSuccess()
}
+ @Test
+ void test_notify_pr_with_unstable_and_multiline_steps_failures() throws Exception {
+ script.notifyPR(
+ build: readJSON(file: "build-info.json"),
+ buildStatus: "UNSTABLE",
+ changeSet: readJSON(file: "changeSet-info.json"),
+ log: f.getText(),
+ statsUrl: "https://ecs.example.com/app/kibana",
+ stepsErrors: readJSON(file: "steps-errors-with-multiline.json"),
+ testsErrors: readJSON(file: "tests-errors.json"),
+ testsSummary: readJSON(file: "tests-summary.json")
+ )
+ printCallStack()
+ assertTrue(assertMethodCallContainsPattern('githubPrComment', '`auditbeat-Lint - make -C auditbeat check;make -C auditbeat update;make -C x-pack/auditbeat check;`'))
+ assertJobStatusSuccess()
+ }
+
@Test
void test_notify_pr_with_unstable_and_multiple_steps_failures() throws Exception {
script.notifyPR(
diff --git a/src/test/resources/steps-errors-with-multiline.json b/src/test/resources/steps-errors-with-multiline.json
new file mode 100644
index 000000000..3af6f7e86
--- /dev/null
+++ b/src/test/resources/steps-errors-with-multiline.json
@@ -0,0 +1,26 @@
+[
+ {
+ "displayDescription": "make -C auditbeat check;make -C auditbeat update;make -C x-pack/auditbeat check;make -C x-pack/auditbeat update;make check-no-changes;",
+ "displayName": "auditbeat-Lint - make -C auditbeat check;\nmake -C auditbeat update;\nmake -C x-pack/auditbeat check;\n",
+ "durationInMillis": 78948,
+ "id": "1662",
+ "input": null,
+ "result": "FAILURE",
+ "startTime": "2021-02-16T14:15:06.350+0000",
+ "state": "FINISHED",
+ "type": "STAGE",
+ "url": "https://beats-ci.elastic.co//blue/rest/organizations/jenkins/pipelines/Beats/pipelines/beats/pipelines/PR-23966/runs/5/steps/1662/log"
+ },
+ {
+ "displayDescription": "Error 'hudson.AbortException: script returned exit code 2'",
+ "displayName": "Error signal",
+ "durationInMillis": 13,
+ "id": "1808",
+ "input": null,
+ "result": "FAILURE",
+ "startTime": "2021-02-16T14:16:25.317+0000",
+ "state": "FINISHED",
+ "type": "STEP",
+ "url": "https://beats-ci.elastic.co//blue/rest/organizations/jenkins/pipelines/Beats/pipelines/beats/pipelines/PR-23966/runs/5/steps/1808/log"
+ }
+]