Skip to content

Commit

Permalink
update version to 3.2 and doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume DeMengin committed Aug 16, 2022
1 parent b7d755c commit e98a013
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand All @@ -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_
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -557,6 +576,7 @@ Note:
## Known limitations <a name="limitations"></a>

* 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)

Expand Down Expand Up @@ -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
26 changes: 24 additions & 2 deletions vars/logparser.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,15 @@
</dd>
<dt>
<b><code>String getLogsWithBranchInfo(java.util.LinkedHashMap options = [:], RunWrapper build = currentBuild)</code></b><br>
<br>
<b><code>void archiveLogsWithBranchInfo(String name, java.util.LinkedHashMap options = [:])</code></b>
<b><code>void archiveLogsWithBranchInfo(String name, java.util.LinkedHashMap options = [:])</code></b><br>
<b><code>void writeLogsWithBranchInfo(hudson.FilePath filePath, java.util.LinkedHashMap options = [:], build = currentBuild)</code></b><br>
<b><code>void writeLogsWithBranchInfo(String node, String path, java.util.LinkedHashMap options = [:], build = currentBuild)</code></b><br>
</dt>
<dd>
<p>
get logs with branch name on each branch line<br>
or archive them in run artifacts<br>
or write them in a file on one of the nodes<br>
<br>
available options:
<ul>
Expand Down Expand Up @@ -284,6 +286,26 @@
&nbsp;&nbsp;[branch2] in branch2<br>
</code><br>
</li>
<li>
<b>write logs directly to a file</b><br>
<code><br>
&nbsp;&nbsp;echo 'not in any branch'<br>
&nbsp;&nbsp;parallel (<br>
&nbsp;&nbsp;&nbsp;&nbsp;branch1: { echo 'in branch1' },<br>
&nbsp;&nbsp;&nbsp;&nbsp;branch2: { echo 'in branch2' }<br>
&nbsp;&nbsp;)<br>
&nbsp;&nbsp;node('myhost') {<br>
&nbsp;&nbsp;&nbsp;&nbsp;logparser.writeLogsWithBranchInfo(env.NODE_NAME, "${pwd()}/logs.txt")<br>
&nbsp;&nbsp;}<br>
</code><br>
result: logs.txt in workspace on node 'myhost' with content:<br>
<code><br>
&nbsp;&nbsp;not in any branch<br>
&nbsp;&nbsp;[branch1] in branch1<br>
&nbsp;&nbsp;[branch2] in branch2<br>
&nbsp;&nbsp;Running on myhost in /home/jenkins/workspace/test-pipeline<br>
</code><br>
</li>
<li>
<b>filter branch logs</b> with option <code>filter=[ list of branches to keep ]</code>
<ul>
Expand Down

0 comments on commit e98a013

Please sign in to comment.