# Jenkins Pipelines Integration

This article will guide you on how you may integrate vREST NG with Jenkins Pipelines via the vrest-ng-cli module.

# Download configuration file

Please download the Jenkinsfile from the line below and save it in the root directory of your source code repository. And you may modify it as per your own needs. Download Jenkins Pipelines File (without NPM)(opens new window)
Download Jenkins Pipelines File (via NPM)(opens new window)

# Explanation

The process contains the following major steps in order to integrate the vrest-ng-cli module. The steps are written on the basis of the ubuntu machine.

  1. Download and install vREST NG CLI binary:

    First, download and install the vREST NG CLI module.

    Via NPM way

    ...
    environment {
      vrest_version = '2.0.0' 
      HOME = '.'
    }
    stages {
      stage('Build') {
        steps {
          sh 'npm install'
          sh 'npm install vrest-ng-cli@$vrest_version'
        }
      }
    }
    ...
    

    Note: Change the vREST NG CLI version to the latest version. Version 2.0.0 was the latest version of the vREST NG CLI module while writing this guide.

  2. # Execute vREST NG Tests

    To execute the vREST NG tests, use the following code. For detailed information on the vrest-ng-cli command-line options, please follow this guide link.

    ...
    stage('Test') { 
      steps {
        sh 'npm run start &'
        sh 'npx vrest-ng-cli run --projectdir=./test/ddt-tests --env=default --logger=xunit' 
      }
    }
    ...
    
  3. # Publish Test Results

    Finally, publish the test results produced by the xunit logger of the vrest-ng-cli module. By default vrest-ng-cli module exports the report in the vrest_logs/logs.xml of the current working directory. So, we can use those generated reports to publish them on the Jenkins server.

    ...
    post {
      always {
        junit 'vrest_logs/logs.xml'
      }
    }
    ...
    

# Reporting

vrest-ng-cli module generates the following types of reports in Jenkins pipelines:

  1. Console Report
  2. Test Run Results
  3. Single Test Case Failure Report