Skip to content

Return clean JSON result #118

@NVBPF

Description

@NVBPF

Is your feature request related to a problem? Please describe.

When getting the output of a command via the feature introduced in #113, the full output of the command is returned, even if called with --format json or --format simple-json, making the result not parseable as JSON due to several lines of informational output before the JSON-formatted output is returned.

Describe the solution you'd like to see

If --format json or --format simple-json are set, only return the JSON output if returned in a script.

script {
    String result = jf 'audit --format json'
    def json = new JsonSlurper().parseText(result)
}

Describe alternatives you've considered

No response

Additional context

Current result of trying to parse result as JSON:

09:31:48 [Info] Performing scans on 1 targets:
[
  {
    "target": "/var/jenkins/workspace/something",
    "technology": "maven"
  }
]
09:31:48 [Info] Not entitled for JAS, skipping advance security scans...
09:31:48 [Info] Calculating Maven dependencies...
...........
A JSON payload should start with an openning curly brace '{' or an openning square bracket '['.
Instead, '09' was found on line: 1, column: 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions