From ebe36989136e7c630a39b1b79eb3b6a935441c93 Mon Sep 17 00:00:00 2001 From: Manuele Simi Date: Wed, 3 Feb 2021 21:07:26 -0500 Subject: [PATCH 1/4] Add new filter_with parameter and filter the report. --- Jenkinsfile | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5658f6e..378c5fa 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -54,7 +54,9 @@ pipeline { string(name: 'action_file', defaultValue: '', description: 'The relative path of the Bash fragment to execute.') - + string(name: 'filter_with', + defaultValue: '', + description: 'If not empty, only actions including this filter in their output will be reported.') } @@ -178,15 +180,16 @@ def exec(repo_url, repo_name) { output = sh(script: bashWrapper, returnStdout: true)?.trim() } } - def xml_action = """ - - - ${output} - - - """ - sh "echo -e '${xml_action}' >> $ACTION_OUTPUT" - + if (filter_with && output.contains(filter_with) { + def xml_action = """ + + + ${output} + + + """ + sh "echo -e '${xml_action}' >> $ACTION_OUTPUT" + } } //a non CPS method is necessary for the usage of splitEachLine() From 28b3da1a9602e4c3023eaf161cb8ec900251f4bf Mon Sep 17 00:00:00 2001 From: Manuele Simi Date: Wed, 3 Feb 2021 21:09:47 -0500 Subject: [PATCH 2/4] Fix syntax. --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 378c5fa..3c4d1a2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -180,7 +180,7 @@ def exec(repo_url, repo_name) { output = sh(script: bashWrapper, returnStdout: true)?.trim() } } - if (filter_with && output.contains(filter_with) { + if (filter_with && output.contains(filter_with)) { def xml_action = """ From 685bee0b2f3e02f35ccdfc995df93b4f27b9800c Mon Sep 17 00:00:00 2001 From: Manuele Simi Date: Wed, 3 Feb 2021 21:18:00 -0500 Subject: [PATCH 3/4] Manage when the filter is empty. --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3c4d1a2..88dfd91 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -180,7 +180,7 @@ def exec(repo_url, repo_name) { output = sh(script: bashWrapper, returnStdout: true)?.trim() } } - if (filter_with && output.contains(filter_with)) { + if ((!filter) || (filter_with && output.contains(filter_with))) { def xml_action = """ From a58a6ca6a448a37e6f97e133aaa59c6c05e0d5da Mon Sep 17 00:00:00 2001 From: Manuele Simi Date: Wed, 3 Feb 2021 21:37:41 -0500 Subject: [PATCH 4/4] Fix param name. --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 88dfd91..cfa3f76 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -180,7 +180,7 @@ def exec(repo_url, repo_name) { output = sh(script: bashWrapper, returnStdout: true)?.trim() } } - if ((!filter) || (filter_with && output.contains(filter_with))) { + if ((!filter_with) || (filter_with && output.contains(filter_with))) { def xml_action = """