Including Code Analysis in a Continuous Integration Process

There are various way you can integrate code analysis into a continuous integration (CI) framework and a number of plugins that enhance the features.

The following provides some guidelines on how to configure Jenkins for analyzing Eclipse COBOL projects:

Setup
Before you start, you must have a machine that has Visual COBOL for Eclipse installed. The machine must be attached to Jenkins and must have Apache Ant installed.
Integrate code analysis
  1. Create a Jenkins job for analyzing COBOL projects.
  2. Configure the job that so it runs the following commands from a Windows batch command:
    rem use the following script to set the COBOL environment:
    call "product-install-dir\CreateEnv.bat"
    rem change to the directory on the machine that stores the COBOL sources and the .cobolBuild file:
    cd workspace-dir
    rem set the classpath environment variable:
    set CLASSPATH=product-install-dir\bin\mfant.jar;%CLASSPATH%
    rem perform code analysis using the .cobolBuild script:
    ant -f .cobolBuild build.and.analyze -DanalysisFailOnError=true
  3. Optionally, you can use any suitable plugins for Jenkins to customize things such as the reports from code analysis. For example, you can use the free Log Parser Plugin (available from the Jenkins Web site) to provide better formatting of the reports.