By default, Detect for Jenkins downloads either the latest Detect shell script when run on a UNIX node, or PowerShell script when it's run on a Windows node, to the Jenkins tools directory, and then executes that script. Note that you can also use the JAR option to run Detect.
The Detect PowerShell or shell script is downloaded once and placed in the Detect working directory. If you want to force the plugin to fetch the latest script, clear out the Detect directory in your Jenkins tools directory.
JAR option
If you do not want to download Detect, you can manually put the JAR on the node where you want Detect to run and specify the DETECT_JAR environment variable that points to your provided JAR, and that JAR will be executed instead.
To use the JAR option, perform the following steps:
Navigate to Dashboard > Manage Jenkins > Configure System > Global properties > Environment variables.
Click Add.
Set an environment variable with the following properties:
Name:
DETECT_JAR.Value:
<path to the Detect jar file on your Jenkins node>.
Note: When your build runs, Jenkins looks for configured environment variables, and if it locates DETECT_JAR, it uses that instead of pulling the latest Detect shell script.
Air Gap option
Detect can be configured to run in an air gap fashion, see: Air Gap.
In freestyle and Pipeline jobs, you can toggle between the different modes for running Detect in the plugin such as pulling the Detect.jar from scripts or $DETECT_JAR_PATH, or from a specified Tool Installation.
Running Detect in a job
You can run Detect as a post-build action or a Pipeline step.
Pipeline step
You can configure the scan as a pipeline step in a Pipeline job.
Refer to the pipeline example
Post-build actions
You can configure the scan as a post-build action in a freestyle job. You can have multiple post-build actions, but only one Detect post-build action.
Refer to the freestyle example.
DSL considerations
The Detect for Jenkins plugin provides Dynamic DSL for both freestyle steps and pipeline steps. Read more at Dynamic DSL.
Note: that versions 1.83 and later of the DSL plugin do not support the Detect for Jenkins plugin pipeline steps.