Quick guide to setup C/C++test Professional (Static Analysis) on Jenkins

Andrey MadanAndrey Madan Posts: 378 ✭✭✭
edited June 25 in C/C++test

This guide will Comprise of 3 Major Parts:

1 - Initial Project Setup
2 - Running from a command line in Jenkins
3 - Setting up the license on the CI/CD (Jenkins) Machine

Part 1 : Initial Project Setup

Step 1.1 Creating your Build Data file (.bdf)

This is the command I used to create the .bdf :

/home/jamie/Parasoft/cpptest/bin/cpptesttrace --cpptesttraceOutputFile=/home/jamie/Parasoft/sandbox/Timer_A/Timer_myJenk_SA.bdf --cpptesttraceProjectName=Timer_Jenk_SA make clean all 

Note : the option --cpptesttraceOutputFile describes the name and the location where the .bdf will reside - always use absolute path names

Note : the option --cpptesttraceProjectName sets the name of the C++test project - a unique name must be used in a single workspace

Step 1.2 Setting up your license

Select : Network

Point to the DTP license server (in my case local host)

Select Desktop Compliance Edition

Select Apply and Close

Step 1.3 : Create your project in C++test Professional - In this Example we imported the .bdf Timer_myJenk_SA.bdf for the Timer_Jenk Project

Step 1.4 - Optional step - Run MISRA 2012 static analysis on your project

Step 1.5 : Create your Static Analysis - Test Configuration is this example we created the "Jamie_MISRA_2012" test configuration

Step 1.6 : Export out your Test Configuration

Step 1.7 : I am storing the these files in a directory locally called /home/jamie/Parasoft/jamie_data

Step 1.8: Go to the Menu Parasoft | Preferences | Reports

for Format select "xUnit"

Apply

Step 1.9: Go to the Menu Parasoft | Preferences | Parasoft

Click on the "share" link

Step 1.10 : Give the localsettings file that we will export a name ... in the case "June_local_dtp"

Select ALL

Hit OK

Step 1.11 - Place the "June_local_dtp" in the /home/jamie/Parasoft/jamie_data directory

Step 1.12 : Go to the location of the C++Test Prof workspace

Note that the Timer_Jenk_SA Project is stored here

Copy the Timer_Jenk_SA directory (and subfolders) --- This contains the .parasoft file, the .cproject file, the .project file, the tests dir and your stubs dir

to the machine where you will be doing the Jenkins build

In my example I placed the Timer_Jenk_SA folder in ../myProjects/ dir

NOTE : Parasoft recommends storing the the .project and .parasoft files at the top level of your source directory

Step 1.13 : Copy the directory /home/jamie/Parasoft/jamie_data/
to the machine where you will be doing the Jenkins build

PART 2 - Running from a command line in Jenkins

On Build Box (CI/CD machine) in this Case Jenkins

Step 2.1 : You should have the jamie_data directory and the workspace project directory on the Jenkins box

Step 2.2 : Create a new Jenkins project

Step 2.3 : Setting up the Jenkins execute shell:

This is the cli command I used:

/home/jamie/Parasoft/cpptest/cpptestcli -import /home/jamie/Parasoft/myProjects/ -resource "Timer_Jenk_SA" -config /home/jamie/Parasoft/jamie_data/Jamie_MISRA_2012.properties -localsettings /home/jamie/Parasoft/jamie_data/June_local_dtp -report /var/lib/jenkins/workspace/Timer_Jenkins_SA

-import /home/jamie/Parasoft/myProjects/ ... This option allows the build machine to import the project into the jenkins/parasoft from your other machine or source control

-resource "Timer_Jenk_SA" -- selects the desired project

-config /home/jamie/Parasoft/jamie_data/Jamie_MISRA_2012.propertie --- this options selects the test configuration we will use in the build --- in this case Unit Testing

-localsettings /home/jamie/Parasoft/jamie_data/June_local_dtp this option has all the parasoft settings such as license, dtp location, report type etc

-report /home/jamie/Parasoft/reportsSA --- this is the location where the reports will be written to (note the Jenkins user must have write rights to that location)

(optional -publish -- this option will allow you to publish to DTP )

Step 2.4 : Build in Jenkins:

Step 2.5 Setting up the Parasoft Jenkins Plugin

Go to Manage Jenkins

Select Manage Plugins

Step 2.6 Verify the "Parasoft Findings" plugin is installed - if not install the plugin and restart Jenkins

Step 2.7 Configure the Parasoft Plugin

Go back to your Jenkins project and select "Configure"

Select "Add Post-Build Action

Step 2.8

From the drop down select :

Record compiler warnings and static Analysis Results

Step 2.9
for Tool : Select "Parasoft Findings"
Report File Patterns : enter : "report.xml"
Save

Step 2.10 Perform another Jenkins build

Part 3 Licensing

Step 3.1

When we were working at the desktop (non CI / CD ) machine we used the Desktop Compliance Edition also note we consumed this license from the license server on DTP.

This setup is illustrated here (also see attachment "June_local_DTP" )

Step 3.2

When we were working at the desktop (non CI / CD ) machine we used the Automation Compliance Edition also note we consumed this license from the license server on DTP.

This setup is illustrated here (also see attachment "July_local_dtp" )

Step 3.3

The main take away from this illustration - I could have just exported out the localsettings file from my "Desktop" machine copied to to my CI/ CD machine and just edited line 6.

Appendix:

https://docs.parasoft.com/display/FINDS/Parasoft+Findings+for+Jenkins

https://www.evernote.com/l/Ajde0-CgRaBLZqZQN4PegJ9zJO76TTUZgis/

Sign In or Register to comment.