Integrating Ocular with Jenkins Pipelines

The Jenkins plugin for Ocular allows you to automate code analysis during the build process using Ocular.

Prerequisites

This article assumes that you have installed Jenkins and have an existing Pipeline project.

Setting Up the Jenkins Plugin for Ocular

Download the sl-ocular-scan plugin and upload it to your environment.

Next, set Jenkins to run Ocular as a final build step in a Pipeline project by adding the following to your Jenkinsfile:

pipeline {
agent any
stages {
stage('Ocular Scan') {
steps {
slOcularScan(
artifact: "ARTIFACT_URL",
threadFix: false,
debug: true,
ocularArgs: "-J-Xmx4000m",
orgId: "ORG_ID",
accessToken: "ACCESS_TOKEN"
)
}
}
}
}
}

Note that slOcularScan requires several parameters; be sure to change them as appropriate during configuration:

Parameter

Description

artifact

The link to the file you want analyzed

threadFix

Optional. Whether you want a ThreadFix file generated

debug

Optional. Whether you want debugging information

ocularArgs

Optional. Any parameters you want included in your command to run Ocular

orgId

Your ShiftLeft Organization ID. Can be found in the Dashboard under Account Settings

accessToken

Your ShiftLeft Access Token. Can be found in the Dashboard under Account Settings

Once you've configured the plugin, you can run a build to see the results.