What does the Kiuwan plugin for Jenkins do
Kiuwan Plugin for Jenkins allows to execute Kiuwan analysis as a Post-build action.
If you need to execute Kiuwan a stage within a Jenkins Pipeline, please go to Jenkins Pipeleline
Once you installed and configure the Kiuwan plugin in your Jenkins installation, you will be able to run a Kiuwan analysis after build process.
After execution, and based on analysis results, you will be able to mark the build (SUCCESS, UNSTABLE, FAILURE, etc) according to Kiuwan analysis results.
Also, after the build process, Kiuwan Plugin for Jenkins adds a link to analysis results (in your Kiuwan account) from the execution build page.
How to install
Enter your Jenkins dashboard, Select ‘Manage Jenkins’, then ‘Manage Plugins’ and then, from the top tabs, select ‘Available’. In the list you can find Kiuwan Plugin using search function of your browser or using the search box provided by Jenkins. You must check and install.
How to configure
Click on “Manage Jenkins” and then “Configure System”. Then scroll down to the “Kiuwan Global Setting” section.
You need to configure your Kiuwan account credentials (username and password of your Kiuwan account).
If connectivity to Internet is through a proxy, you can configure your proxy setting by clicking Configure Proxy checkbox to provide the requested parameters.
You can validate connectivity clicking “Validate Credentials”.
How to run analysis in build process
Kiuwan analysis is executed as a Post-build action.
To run Kiuwan, in your project configuration you should add a Post action named "Analyze your source code with Kiuwan!".
Three options are available:
- Baseline Mode: In this mode, you can execute a baseline analysis, check its results, and change the status of your build if the selected measure does not meet the selected thresholds.
- Delivery Mode: If you have a subscription with deliveries, you can execute a delivery analysis choosing this mode.
- Expert Mode: If you want to indicate Kiuwan Local Analyzer's command line options and extra parameters manually, this is your option.
Selection of Baseline Mode configures Kiuwan Plugin for Jenkins to define the analysis scope as “baseline”.
Kiuwan Application Name should be configured to the application name as it’s defined in Kiuwan. If the app does not exist, it will be created. If not set, Jenkins project name will be used.
Analysis Label lets identify the analysis. If not set, Jenkins build number (#n) will be used.
Clicking on Advanced button you will be able to define additional configuration parameters such as default encoding to be used in the analysis, include/exclude patterns, timeout and languages.
You can find online help on these configuration parameters clicking the question mark (?).
Timeout indicates the maximum allowed time (in minutes) for Jenkins to wait for Kiuwan analysis. Once that time is reached, build will be set as ABORTED.
Please, note that this timeout will alse be passed to Kiuwan Local Analyzer as timeout for its internal tasks (rules, metrics and clones), overriding so timout value set in AGENT_HOME/conf/analyzer.properties).
So, please be careful to set Jenkins timeout value high enough to allow Kiuwan to finalize the analysis.
These configuration values will override parameter values set in JENKINS_HOME/tools/KiuwanLocalAnalyzer/conf/analyzer.properties.
For any other configuration parameter not shown in this configuration page, you should edit analyzer.properties file.
In Baseline mode, you can set the build status depending on thresholds based on indicators of Kiuwan Analysis:
- Quality indicator
- Risk Index
- Effort to Target
You can define thresholds to mark the build as UNSTABLE and FAILURE depending on indicator values as the above picture shows.
Selection of Delivery Mode configures Kiuwan Plugin for Jenkins to define the analysis scope as “Delivery” (partial or complete).
As in Baseline mode, you need to define Kiuwan Application Name and Analysis Label.
Also, clicking on Advanced button will allow you to set additional parameters:
Special importance has Analysis Scope parameter:
- Complete Delivery
- Partial Delivery
Please, see note on Baseline mode about “timeout” specification.
Wait For Audit Results checkbox allows to mark the build depending on the result of the Audit associated to the Kiuwan application. If checked, the build will be marked as UNSTABLE in case the Audit fails.
Selection of Expert Mode allows full control on Kiuwan analysis configuration.
Expert Mode allows to set/override any parameter value configured in JENKINS_HOME/tools/KiuwanLocalAnalyzer/conf/analyzer.properties
By clicking on Advanced button, you can bind the result codes of Kiuwan Local Analyzer with Jenkins' build results.
You can find further reference on return codes in Local Analyzer Return Codes
In order to execute Kiuwan as a stage in Jenkins Pipeline you need to install Kiuwan Local Analyzer (KLA) into the Jenkins node.
- To install KLA, please follow instructions as described in KLA - Installation and Network Configuration
It's highly recommended to install KLA with the same user that will execute KLA when launched from Jenkins Pipeline.
In case installation and execution users be different, make sure that execution user has read-write-execute permissions over KLA installation directory and subdirectories.
Once KLA is installed at the Jenkins node, in order to execute Kiuwan as a stage in Jenkins Pipeline you can use next Groovy script as a basis:
- Please note that you must first generate credentials (through Jenkins' Credentials Plugin, https://plugins.jenkins.io/credentials )
- You can find detailed info on available Command Line Interface options of KLA at Kiuwan Local Analyzer CLI - Command Line Interface