How to integrate Highlight’s Command Line in a Jenkins Pipeline

As the Highlight command line is a real hit across users who want to automate the scan of their code bases, we thought it could be helpful to provide a series of templates and code samples for the different build tools where you would integrate our code scans.

The script below illustrates how to integrate the command line within a Jenkins pipeline.

#!/usr/bin/env groovy

// Basic template for using CAST Highlight command line within a Jenkins pipeline
// To be adapted to your use case.

// Assuming Highlight client tarball is decompressed in JENKINS_HOME
// Assuming Java and Perl installed

node {

    // Get your source code
    stage("Get sources") {
        // git "myrepo..." or svn "myrepo..."
    //Build stage
    stage("Build") {
      // apply your build steps...
    // Scan with Highlight
    // Assuming the Highlight command line is extracted under JENKINS_HOME

       stage("HL analysis") {      
        sh '''java -jar  $JENKINS_HOME/Highlight-Automation-Command/HighlightAutomation.jar \
                  --analyzerDir "$JENKINS_HOME/Highlight-Automation-Command/perl" \
                  --workingDir "$WORKSPACE" \
                  --sourceDir "$WORKSPACE"  \
                  --ignoreDirectories ".git" \


Want to use our command line from another tool? Don’t hesitate to contact us, we’ll try to post a script sample for your environment in the coming articles.