Skip to content
This repository was archived by the owner on Oct 28, 2024. It is now read-only.
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
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ ${errorStackTrace}

<!-- STEPS ERRORS IF ANY -->
<% errorGitHub = stepsErrors?.find{it?.result == "FAILURE" && it?.displayName?.contains('Notifies GitHub')}%>
<% stepsErrors = stepsErrors?.findAll{it?.result == "FAILURE" && !it?.displayName?.contains('Notifies GitHub') && !it?.displayName?.contains('Archive JUnit')}%>
<% errorDeleteDir = stepsErrors?.find{it?.result == "FAILURE" && it?.displayName?.contains('Recursively delete the current directory from the workspace')}%>
<% stepsErrors = stepsErrors?.findAll{it?.result == "FAILURE" && !it?.displayName?.contains('Notifies GitHub') && !it?.displayName?.contains('Archive JUnit') && !it?.displayName?.contains('Recursively delete the current directory from the workspace')}%>
<% errorSignal = stepsErrors?.find{it?.displayName?.contains('Error signal')}%>
<% stepsErrors = stepsErrors?.findAll{ !it?.displayName?.contains('Error signal') } %>
<% if (errorSignal) { stepsErrors = stepsErrors << errorSignal }%>
<% if (errorDeleteDir) { stepsErrors = stepsErrors << errorDeleteDir }%>
<% if (stepsErrors?.size() <= 0 && !buildStatus?.equals('SUCCESS') && errorGitHub) {%>
<% stepsErrors = stepsErrors << errorGitHub %>
<%}%>
Expand Down
8 changes: 8 additions & 0 deletions src/test/groovy/ApmBasePipelineTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,14 @@ class ApmBasePipelineTest extends DeclarativePipelineTest {
}
}

def assertMethodCallContainsPatternOccurrences(String methodName, String pattern, int compare) {
return helper.callStack.findAll { call ->
call.methodName == methodName
}.any { call ->
((callArgsToString(call) =~ /${pattern}/).count) == compare
}
}

def assertMethodCall(String methodName) {
return helper.callStack.find { call ->
call.methodName == methodName
Expand Down
19 changes: 19 additions & 0 deletions src/test/groovy/NotificationManagerStepTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,25 @@ class NotificationManagerStepTests extends ApmBasePipelineTest {
assertJobStatusSuccess()
}

@Test
void test_notify_pr_with_failure_and_deleteDir_issues() throws Exception {
script.notifyPR(
build: readJSON(file: "build-info.json"),
buildStatus: "FAILURE",
changeSet: readJSON(file: "changeSet-info.json"),
log: f.getText(),
statsUrl: "https://ecs.example.com/app/kibana",
stepsErrors: readJSON(file: "steps-errors-with-deleteDir-issue.json"),
testsErrors: [],
testsSummary: readJSON(file: "tests-summary.json")
)
printCallStack()
assertTrue(assertMethodCallContainsPattern('githubPrComment', 'Build Failed'))
assertTrue(assertMethodCallContainsPattern('githubPrComment', 'Shell Script'))
assertTrue(assertMethodCallContainsPatternOccurrences('githubPrComment', 'Recursively delete the current directory from the workspace', 1))
assertJobStatusSuccess()
}

@Test
void test_notify_pr_with_a_generated_comment() throws Exception {
script.notifyPR(comment: 'My Comment')
Expand Down
50 changes: 50 additions & 0 deletions src/test/resources/steps-errors-with-deleteDir-issue.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[
{
"displayDescription": "Unable to delete 'C:\\Users\\jenkins\\workspace\\Beats_beats_PR-22662'. Tried 3 times (of a maximum of 3",
"displayName": "Recursively delete the current directory from the workspace",
"durationInMillis": 270827,
"id": "12168",
"input": null,
"result": "FAILURE",
"startTime": "2021-02-18T16:23:33.466+0000",
"state": "FINISHED",
"type": "STEP",
"url": "https://beats-ci.elastic.co//blue/rest/organizations/jenkins/pipelines/Beats/pipelines/beats/pipelines/PR-22662/runs/3/steps/12168/log"
},
{
"displayDescription": "Unable to delete 'C:\\Users\\jenkins\\workspace\\Beats_beats_PR-22662'. Tried 3 times (of a maximum of 3",
"displayName": "Recursively delete the current directory from the workspace",
"durationInMillis": 282224,
"id": "11714",
"input": null,
"result": "FAILURE",
"startTime": "2021-02-18T16:22:37.478+0000",
"state": "FINISHED",
"type": "STEP",
"url": "https://beats-ci.elastic.co//blue/rest/organizations/jenkins/pipelines/Beats/pipelines/beats/pipelines/PR-22662/runs/3/steps/11714/log"
},
{
"displayDescription": "Unable to delete 'C:\\Users\\jenkins\\workspace\\Beats_beats_PR-22662'. Tried 3 times (of a maximum of 3",
"displayName": "Recursively delete the current directory from the workspace",
"durationInMillis": 193494,
"id": "12939",
"input": null,
"result": "FAILURE",
"startTime": "2021-02-18T16:24:40.836+0000",
"state": "FINISHED",
"type": "STEP",
"url": "https://beats-ci.elastic.co//blue/rest/organizations/jenkins/pipelines/Beats/pipelines/beats/pipelines/PR-22662/runs/3/steps/12939/log"
},
{
"displayDescription": null,
"displayName": "Shell Script",
"durationInMillis": 101825,
"id": "58",
"input": null,
"result": "FAILURE",
"startTime": "2021-02-18T16:24:40.836+0000",
"state": "FINISHED",
"type": "STEP",
"url": "https://beats-ci.elastic.co//blue/rest/organizations/jenkins/pipelines/Beats/pipelines/beats/pipelines/PR-22662/runs/3/steps/58/log"
}
]