From e98a01336854de09cffb0e31123bbcdd6d607cd6 Mon Sep 17 00:00:00 2001 From: Guillaume DeMengin Date: Tue, 16 Aug 2022 23:06:37 +0200 Subject: [PATCH] update version to 3.2 and doc --- Jenkinsfile | 2 +- README.md | 27 +++++++++++++++++++++++++-- vars/logparser.txt | 26 ++++++++++++++++++++++++-- 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a9eec12..89e4c51 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -27,7 +27,7 @@ RUN_MANYTHREAD_TIMING_TEST = params.MANYTHREAD_TIMING_TEST == true // ============================ // = import logparser library = // ============================ -// @Library('pipeline-logparser@3.1.3') _ +// @Library('pipeline-logparser@3.2') _ node(LABEL_TEST_AGENT) { checkout scm def rev=sh(script: 'git rev-parse --verify HEAD', returnStdout: true).trim() diff --git a/README.md b/README.md index 98d643b..d4f66da 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Tested with: ### import pipeline-logparser library in Jenkinsfile import library like this ``` -@Library('pipeline-logparser@3.1.3') _ +@Library('pipeline-logparser@3.2') _ ``` _identifier "pipeline-logparser" is the name of the library set by jenkins administrator in instance configuration:_ * _it may be different on your instance_ @@ -48,7 +48,7 @@ def mylog = logparser.getLogsWithBranchInfo() ### Detailed Documentation -see online documentation here: [logparser.txt](https://htmlpreview.github.io/?https://github.com/gdemengin/pipeline-logparser/blob/3.1.3/vars/logparser.txt) +see online documentation here: [logparser.txt](https://htmlpreview.github.io/?https://github.com/gdemengin/pipeline-logparser/blob/3.2/vars/logparser.txt) * _also available in $JOB_URL/pipeline-syntax/globals#logparser_ * _visible only after the library has been imported once_ * _requires configuring 'Markup Formater' as 'Safe HTML' in $JENKINS_URL/configureSecurity_ @@ -249,6 +249,25 @@ functionalities: [branch2] in branch2 ``` +- write logs directly to a file + ``` + echo 'not in any branch' + parallel ( + branch1: { echo 'in branch1' }, + branch2: { echo 'in branch2' } + ) + node('myhost') { + logparser.writeLogsWithBranchInfo(env.NODE_NAME, "${pwd()}/logs.txt") + } + ``` + result: log.txt in workspace on node 'myhost' with content: + ``` + not in any branch + [branch1] in branch1 + [branch2] in branch2 + Running on myhost in /home/jenkins/workspace/test-pipeline + ``` + - filter branch logs with option `filter=[ list of branches to keep ]` * filter by name @@ -557,6 +576,7 @@ Note: ## Known limitations * calls to `logparser.getLogsWithBranchInfo()` may fail (and cause job to fail) when log is too big (millions of lines, hundreds of MB of logs) because of a lack of heap space +workarround: use `logparser.writeLogswithBranchInfo` to write logs directly in a file (in node workspace) or `logparser.archiveLogsWithBranchInfo()` to write them directly in run artifacts * logs of nested stages (stage inside stage) are not correctly handled in Blue Ocean (Blue Ocean limitation) @@ -645,3 +665,6 @@ Note: * 3.1.3 (06/2022) - fix parsing of completed jobs #16 + +* 3.2 (08/2022) + - add function to write directly to a file #21 diff --git a/vars/logparser.txt b/vars/logparser.txt index 278a5e0..c2268a4 100644 --- a/vars/logparser.txt +++ b/vars/logparser.txt @@ -91,13 +91,15 @@
String getLogsWithBranchInfo(java.util.LinkedHashMap options = [:], RunWrapper build = currentBuild)
-
- void archiveLogsWithBranchInfo(String name, java.util.LinkedHashMap options = [:]) + void archiveLogsWithBranchInfo(String name, java.util.LinkedHashMap options = [:])
+ void writeLogsWithBranchInfo(hudson.FilePath filePath, java.util.LinkedHashMap options = [:], build = currentBuild)
+ void writeLogsWithBranchInfo(String node, String path, java.util.LinkedHashMap options = [:], build = currentBuild)

get logs with branch name on each branch line
or archive them in run artifacts
+ or write them in a file on one of the nodes

available options: