Skip to main content
Skip table of contents

Jenkins Integration

Jenkins/Cloudbees-CI Integration

This topic provides instructions on how to integrate Jenkins (and Jenkins with Cloudbees CI) with the Unified Agent.

NOTE: Before you begin, make sure that the relevant package manager is installed. For details, see here.

Unified Agent Configuration

The following integration uses environment variables to configure the Unified Agent so that the default configuration values are used.

For more information, see:

Authentication

For all the following examples, you will need to add the Mend apiKey and a userKey to Jenkins Credential Manager, as a secret text.

For more information, see:

Pipeline Job on Linux/Unix and Windows Using CURL

In the 'Pipeline' select Definition: Pipeline script, and add the following lines to the script:

CODE
node {
  environment {
       WS_APIKEY = credentials('mend-apikey')
       WS_WSS_URL = "https://saas.whitesourcesoftware.com/agent"
       WS_USERKEY = credentials('mend-serviceaccount-userkey')
       WS_PRODUCTNAME = "Your Product Name"
       WS_PROJECTNAME = "${JOB_NAME}"
   }
  stage('Download Unified Agent') {
   sh 'curl -LJO https://unified-agent.s3.amazonaws.com/wss-unified-agent.jar'
  }
  stage('Run Unified Agent') {
    sh 'java -jar wss-unified-agent.jar' 
  }
}

Note the following:

  • For Windows, replace sh with bat and download CURL, add it to your PATH environment variable, and restart Jenkins to load the new PATH variable.

  • It is advised to use the download curl command only once a week to download the latest version of the Unified Agent for performance reasons, and not as part of every build. You can do this using a scheduler task, such as cron.

  • You can combine the two stages into one stage.

Pipeline Job on Windows Using PowerShell

In the 'Pipeline', select Definition: Pipeline script and add the following lines to the script:

CODE
node {
  environment {
       WS_APIKEY = credentials('mend-apikey')
       WS_WSS_URL = "https://saas.whitesourcesoftware.com/agent"
       WS_USERKEY = credentials('mend-serviceaccount-userkey')
       WS_PRODUCTNAME = "your-product-name"
       WS_PROJECTNAME = "${JOB_NAME}"
   }
  stage('Download Unified Agent') {
    bat 'powershell bitsadmin /transfer mydownload /dynamic /download /priority FOREGROUND https://unified-agent.s3.amazonaws.com/wss-unified-agent.jar $pwd\wss-unified-agent.jar'
  }
  stage('Run Unified Agent') {
    bat 'java -jar wss-unified-agent.jar'
  }
}

Note the following:

  • Make sure that Background Intelligent Transfer Service (BITS) is enabled on the node running the job.

  • You can combine the two stages into one stage.

Free Style Job on Linux/Unix and Windows Using CURL

  1. Download CURL, add it to your PATH environment variable.

  2. Restart Jenkins in order for it to load the new PATH variable.

  3. Go to Build Environment, click Use secret text(s) or file(s) and add your mend-apikey and mend-userkey credentials

  4. Go to Build, click on Add build step and then select Execute shell, Execute Windows batch command, or Run with timeout.

  5. Add the following commands on the new Command window:

    CODE
    curl -LJO https://unified-agent.s3.amazonaws.com/wss-unified-agent.jar
    set WS_PRODUCTNAME=your-product-name
    set WS_PROJECTNAME=${JOB_NAME}
    set WS_WSS_URL=https://saas.whitesourcesoftware.com/agent
    java -jar wss-unified-agent.jar

Free Style Job on Windows Using PowerShell

  1. Go to Build Environment, click Use secret text(s) or file(s) and add your mend-apikey and mend-userkey credentials.

  2. Go to Build, click on Add build step and then select Execute Windows batch command or Run with timeout.

  3. Add the following commands:

    CODE
    powershell bitsadmin /transfer mydownload /dynamic /download /priority FOREGROUND https://unified-agent.s3.amazonaws.com/wss-unified-agent.jar $pwd\wss-unified-agent.jar 
    set WS_PRODUCTNAME=your-product-name
    set WS_PROJECTNAME=${JOB_NAME}
    set WS_WSS_URL=https://saas.whitesourcesoftware.com/agent
    java -jar wss-unified-agent.jar
    

Note the following:

  • Make sure that Background Intelligent Transfer Service (BITS) is enabled on the node that is running the job.

More Examples

Additional examples of CI/CD pipelines can be found at https://github.com/mend-toolkit/mend-examples/tree/main/CI-CD .  

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.