Skip to content

How to Use checkmarxASTScanner in Jenkins Shared Library (Groovy Script) #390

@prasanthteam

Description

@prasanthteam

Hi Team,

I'm working on integrating the Checkmarx AST Scanner into our Jenkins pipeline using a shared library written in Groovy.

Currently, I am able to invoke the checkmarxASTScanner step directly inside a Jenkinsfile, and it works as expected.

Working example inside Jenkinsfile:

Image

Issue:

When trying to use the checkmarxASTScanner step inside a shared library Groovy method (for example under vars/ or src/), I am unable to import or invoke it properly.

Example that does not work:

Image

The above fails to execute, and I understand it may be because checkmarxASTScanner is a Jenkins pipeline step that needs a Script context.

What I'm Trying to Achieve:

I would like to wrap the checkmarxASTScanner invocation in a reusable shared library method, so I can call it with custom parameters across multiple pipelines, like this:

checkmarxHelper.runScan(this, scanParams)

Questions:

What is the recommended way to invoke checkmarxASTScanner from a shared library?

Is there an API or wrapper class exposed by com.checkmarx.jenkins.CheckmarxScanBuilder that can be used programmatically within a shared library?

Can you provide a working example or best practice for this use case?

Thanks in advance for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions