Page tree

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Kiuwan Plugin Integration into Jenkins

This guide will show you how to install the Kiuwan plugin in Jenkins.

Table of Contents

What the Kiuwan plugin for Jenkins does

The Kiuwan Plugin for Jenkins allows you to execute Kiuwan analysis as a Post-build action.

If you need to execute a Kiuwan stage within a Jenkins Pipeline, please scroll to the Jenkins Pipeline section below.

Download the plugin

Download the Kiuwan Jenkins plugin from Github. It is open source under an MIT license. 

Install the plugin

  1. Enter your Jenkins dashboard

  2. Select Manage Jenkins and then Manage Plugins

  3. From the top tabs, select Available

  4. Find the Kiuwan Plugin using the search function of your browser or the search box provided by Jenkins 

  5. Check and install



How to configure the plugin

  1. Click Manage Jenkins and then Configure System
  2. Scroll down to the Kiuwan Global Settings section. 

  3. Configure your Kiuwan account credentials
  4. If the connectivity to the Internet is through a proxy, configure your proxy setting by clicking the Configure Proxy checkbox to provide the requested parameters
    1. Validate the connectivity by clicking Validate Credentials

How to run an analysis in the build process

The Kiuwan analysis is executed as a post-build action.

To run Kiuwan, add a Post action named "Analyze your source code with Kiuwan!" in your project configuration.

Three options are available:

  • Baseline Mode  
  • Delivery Mode
  • Expert Mode 

Baseline 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.

Selecting Baseline Mode configures the Kiuwan Plugin for Jenkins to define the analysis scope as baseline.



Kiuwan Application Name = configured to the application name defined in Kiuwan. 

  • If the app does not exist, it will be created. 
  • If not set, the Jenkins project name will be used.

Analysis Label = set a lable to identify the analysis.

  • If not set, Jenkins build number (#n) will be used.

Click Advanced to define additional configuration parameters.

  • Encoding type. 
  • Include and Exclude patterns for the analysis. 
  • Timeout = indicates the maximum allowed time (in minutes) for Jenkins to wait for Kiuwan analysis. If that time is reached, the build will be set to ABORTED.  



This timeout will also be passed to the Kiuwan Local Analyzer as a timeout for its internal tasks (rules, metrics and clones), overriding the timeout value set in AGENT_HOME/conf/

Set the 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/

For any other configuration parameter not shown in this configuration page, you should edit the file.


In Baseline mode, you can set the build status depending on thresholds based on indicators of the 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.

Delivery Mode

You can execute a delivery analysis if you have a subscription with deliveries.

Selecting Delivery Mode configures the Kiuwan Plugin for Jenkins to define the analysis scope as Delivery (partial or complete).


As in Baseline mode, you need to define the Kiuwan Application Name and Analysis Label.

Also, clicking Advanced will allow you to set additional parameters:



The Analysis Scope parameter is important:

  • Complete Delivery
  • Partial Delivery

Timeout = see the note in the Baseline mode section about the this specification.

The Wait For Audit Results checkbox allows you 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.



You can configure any parameter by referencing system variables with the syntax ${MY_VAR}


Expert Mode

You can set the Kiuwan Local Analyzer's command line options and extra parameters manually.

Selecting Expert Mode allows full control of the Kiuwan analysis configuration.


Expert Mode allows you to set/override any parameter value configured in JENKINS_HOME/tools/KiuwanLocalAnalyzer/conf/

Click Advanced to 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

The Jenkins Pipeline


In order to execute Kiuwan as a stage in the Jenkins Pipeline you need to install Kiuwan Local Analyzer (KLA) into the Jenkins node.


It's highly recommended to install KLA with the same user that will execute KLA when launched from the Jenkins Pipeline.

In case installation and execution users are different, make sure that the execution user has read-write-execute permissions over the KLA installation directory and subdirectories.


Once KLA is installed in the Jenkins node, in order to execute Kiuwan as a stage in the Jenkins Pipeline you can use the following Groovy script as a basis:


Code Block
stage('invoke analyzer') {
     steps {
         script {
              withCredentials([usernamePassword(credentialsId: '7e163ee4-fb62-432f-8a5e-9b04350277cf',
                        passwordVariable: 'PASSWORD',
                        usernameVariable: 'USERNAME')]) {
                            def returnCode = bat(script: "${AGENT_HOME}/bin/agent.cmd -s \"${WORKSPACE}\" -n \"appPipeline\" -cr \"CR001\" -l ${BUILD_NUMBER} -wr --user \"$USERNAME\" --pass \"$PASSWORD\"",
                            returnStatus: true) 
                                case 0: 
                                case 14: 
                                    currentBuild.result = 'UNSTABLE' 
                                case 1: 
                                case 10: 
                                    currentBuild.result = 'FAILURE' 
                                case 11: 
                                case 12: 
                                    currentBuild.result = 'NOT_BUILT' 
                                case 13: 
                                    currentBuild.result = 'ABORTED' 
                                    currentBuild.result = 'NOT_BUILT' 


View the results

Once you have installed and configured the Kiuwan plugin in your Jenkins installation, you will be able to run a Kiuwan analysis after the build process.

After execution, and based on the analysis results, you will be able to mark the build (SUCCESS, UNSTABLE, FAILURE, etc) according to the Kiuwan analysis results.

After the build process, the Kiuwan Plugin for Jenkins adds a link to the analysis results (visible in your Kiuwan account) on the execution build page.