---
title: "Discussion on \"NPM Audit + Jenkins Warnings Next Generation (Custom Groovy Parser)\" | Hashnode"
description: "Discussion on \"NPM Audit + Jenkins Warnings Next Generation (Custom Groovy Parser)\". At work, I'm developing some projects that use NPM as a package manager. Starting from version 6, NPM will display short audit information at the end of an npm install execution in the following format:\nfound 290 vulnerabilities (283 low, 5 moderate,..."
url: "https://hashnode.com/posts/npm-audit-jenkins-warnings-next-generation-custom-groovy-parser/5f64e86b67d51d3b5d4796b7"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [NPM Audit + Jenkins Warnings Next Generation (Custom Groovy Parser)](https://uko.codes/npm-audit-jenkins-warnings-next-generation-custom-groovy-parser?utm_source=hashnode&utm_medium=feed)

At work, I'm developing some projects that use NPM as a package manager. Starting from version 6, NPM will display short audit information at the end of an npm install execution in the following format: found 290 vulnerabilities (283 low, 5 moderate,...

Sep 18, 2020 · 22 min read · uko.codes  
Updated Dec 9, 2020  
Read the article

-   [#jenkins](https://hashnode.com/tag/jenkins)
-   [#npm](https://hashnode.com/tag/npm)

## Written by

[Yurko Tymchuk](https://hashnode.com/@Uko)

@Uko · Zug, Switzerland

  
[View profile](https://hashnode.com/@Uko)

Objects are like people. They’re living, breathing things that have knowledge inside…

## Responses 3

Markdown supported · ⌘↵ to post

[Timothy Harris](https://hashnode.com/@TheDukeDk)

[Jan 29, 2021](https://hashnode.com/posts/npm-audit-jenkins-warnings-next-generation-custom-groovy-parser/5f64e86b67d51d3b5d4796b7/comment/6013c170fee50e44489b0a00)

Love the guide! Trying it out. Have added the parser with JCasC.

```
warningsParsers:
    parsers:
      - name: "NPM Audit Parser"
        id: npm-audit
        regexp: '\w+\t(\S+)\t(\w+)\t(\S| )+\t((\S| )+)\t(\S+)\t(\S+)'
        script: |
          import edu.hm.hafner.analysis.Severity
          builder.setFileName(matcher.group(7))
          .setCategory(matcher.group(4))
          .setMessage(matcher.group(6))
          .buildOptional()
          return builder.buildOptional();
        example: "update\tlodash\tlow\tnpm update lodash --depth 9\tPrototype Pollution\t\         
        https://npmjs.com/advisories/1523\telasticsearch>lodash\tN"
```

Executing NPM audit in the pipleine like the following.

```
sh 'mkdir -p results/npm-audit'
sh 'npm audit --parseable > results/npm-audit/result.log || true'
```

Added the following to a publish stage.

```
recordIssues(
    tool: groovyScript(parserId: 'npm-audit', pattern: 'results/npm-audit/result.log'),
        qualityGates: [[threshold: 100, type: 'TOTAL', unstable: true]]
)
```

But I keep getting the following error. Any ideas?

```
java.lang.AssertionError: Value is not TRUE
    at edu.hm.hafner.util.Ensure.throwException(Ensure.java:169)
    at edu.hm.hafner.util.Ensure.access$000(Ensure.java:36)
    at edu.hm.hafner.util.Ensure$BooleanCondition.isTrue(Ensure.java:724)
    at edu.hm.hafner.util.Ensure$BooleanCondition.isTrue(Ensure.java:735)
    at io.jenkins.plugins.analysis.warnings.groovy.GroovyParser.createParser(GroovyParser.java:182)
    at io.jenkins.plugins.analysis.warnings.groovy.GroovyParserToolAdapter.createParser(GroovyParserToolAdapter.java:38)
    at io.jenkins.plugins.analysis.warnings.groovy.GroovyScript.createParser(GroovyScript.java:50)
    at io.jenkins.plugins.analysis.core.model.FilesScanner.<init>(FilesScanner.java:55)
    at io.jenkins.plugins.analysis.core.model.ReportScanningTool.scanInWorkspace(ReportScanningTool.java:149)
    at io.jenkins.plugins.analysis.core.model.ReportScanningTool.scan(ReportScanningTool.java:131)
    at io.jenkins.plugins.analysis.core.steps.IssuesScanner.scan(IssuesScanner.java:101)
    at io.jenkins.plugins.analysis.core.steps.IssuesRecorder.scanWithTool(IssuesRecorder.java:681)
    at io.jenkins.plugins.analysis.core.steps.IssuesRecorder.record(IssuesRecorder.java:646)
    at io.jenkins.plugins.analysis.core.steps.IssuesRecorder.perform(IssuesRecorder.java:617)
    at io.jenkins.plugins.analysis.core.steps.RecordIssuesStep$Execution.run(RecordIssuesStep.java:1024)
    at io.jenkins.plugins.analysis.core.steps.RecordIssuesStep$Execution.run(RecordIssuesStep.java:985)
    at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE
```

[FC](https://hashnode.com/@phase)

[Dec 8, 2020](https://hashnode.com/posts/npm-audit-jenkins-warnings-next-generation-custom-groovy-parser/5f64e86b67d51d3b5d4796b7/comment/5fcfed4468eee72c15b564d4)

As someone who is currently implementing NPM audit in our front-end pipelines, this is sooooooo much better than just running npm audit and then linking to the console, which I was doing earler...real life saver!

Only issue I found (if you can call it an issue) was that I had to escape all the backslashes in the regex.. in other words

```
        def newParser = new io.jenkins.plugins.analysis.warnings.groovy.GroovyParser(
            'npm-audit',
            'NPM Audit Parser',
            '\w+\t(\S+)\t(\w+)\t(\S| )+\t((\S| )+)\t(\S+)\t(\S+)',
            ...
```

\->

```
 def newParser = new io.jenkins.plugins.analysis.warnings.groovy.GroovyParser(
                        'npm-audit',
                        'NPM Audit Parser',
                        '\\w+\\t(\\S+)\\t(\\w+)\\t(\\S| )+\\t((\\S| )+)\\t(\\S+)\\t(\\S+)',
```

[Yurko Tymchuk](https://hashnode.com/@Uko)

[Dec 9, 2020](https://hashnode.com/posts/npm-audit-jenkins-warnings-next-generation-custom-groovy-parser/5f64e86b67d51d3b5d4796b7/comment/5fcfed4468eee72c15b564d4#reply-5fd08dc4fb1375358b507a6c)

Thank you for your kind words! As for escaping characters, it always depends on how many times your string is preprocessed and re-evaluated. So it's awesome that you shared also an option that works for you :)

[Sebastian Nilsson](https://hashnode.com/@sebnil)

[Oct 29, 2020](https://hashnode.com/posts/npm-audit-jenkins-warnings-next-generation-custom-groovy-parser/5f64e86b67d51d3b5d4796b7/comment/5f9a3673ae41043093cdbc8c)

Great stuff! But why not just create a pull request to [github.com/jenkinsci/warnings-ng-plugin](https://github.com/jenkinsci/warnings-ng-plugin) to include this npm parser? I am sure a lot of people will use it.

[Yurko Tymchuk](https://hashnode.com/@Uko)

[Oct 29, 2020](https://hashnode.com/posts/npm-audit-jenkins-warnings-next-generation-custom-groovy-parser/5f64e86b67d51d3b5d4796b7/comment/5f9a3673ae41043093cdbc8c#reply-5f9a6eb9ae41043093cdc068)

Hi Sebastian. Yes, this is my ultimate goal. But I had to start somewhere (just to see which data can be extracted from the npm audit log, and to figure out the possibilities of warnings ng). But after your encouragement this is going to happen earlier that otherwise :)

[Sebastian Nilsson](https://hashnode.com/@sebnil)

[Oct 29, 2020](https://hashnode.com/posts/npm-audit-jenkins-warnings-next-generation-custom-groovy-parser/5f64e86b67d51d3b5d4796b7/comment/5f9a3673ae41043093cdbc8c#reply-5f9a8057523ff2502d8e0e12)

Cool! :) I think the difficult job is already done. [Yurko Tymchuk](https://hashnode.com/@Uko)
