Jenkins Integration

Introduction

Jenkins is an open source automation server that helps you to automate the parts of software development related to building, testing, and deploying, facilitating continuous integration and continuous delivery.

circle-info

The following configuration examples show how to install & run the scanner using an API Token stored as a secret named XYGENI_TOKEN. See Generate Xygeni API Token for Scanner or ask your Xygeni administrator to generate it.

It is recommended to store the token as a Jenkins Credentialarrow-up-right of type "Secret text".

Using the xygeni-scanner.zip

Replace <PROJECT_NAME> for the name of the project that you want to create in Xygeni.

pipeline {
  agent any
  environment {
    XYGENI_TOKEN = credentials('XYGENI_TOKEN')
  }
  stages {
    stage('Install Xygeni scanner') {
      steps {
        sh '''
          curl -s -L "https://get.xygeni.io/latest/scanner/xygeni-release.zip" -o xygeni_scanner.zip
          unzip -qq xygeni_scanner.zip -d "${WORKSPACE}"
          rm xygeni_scanner.zip
        '''
      }
    }
    stage('Scan for issues') {
      steps {
        sh '''
          set -x # Activate debug mode to print commands inside the script
          $WORKSPACE/scanner/xygeni scan \
          -n <PROJECT_NAME> \
          --dir ${WORKSPACE}
        '''
      }
    }
  }
}

Using the docker image

If it is not possible to install the scanner in the Jenkins host running the pipeline, you may run the docker image instead.

Replace <PROJECT_NAME> for the name of the project that you want to create in Xygeni.

circle-info

See Xygeni Scanner docker image for more details.

Last updated