Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

If you need to execute Kiuwan a stage within a Jenkins Pipeline, please go to Jenkins Pipeleline

Info

Please visit our post https://www.kiuwan.com/blog/jenkins-integration-kiuwan-code-analysis/ for further info on donwload and public source code.

...

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:

...

 

Code Block
languagegroovy
themeEclipse
stage('invoke analyzer') {
        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) 
                            
                         switch(returnCode){ 
                                case 0: 
                                    break 
                                case 14: 
                                    currentBuild.result = 'UNSTABLE' 
                                    break 
                                case 1: 
                                case 10: 
                                    currentBuild.result = 'FAILURE' 
                                    break 
                                case 11: 
                                case 12: 
                                    currentBuild.result = 'NOT_BUILT' 
                                    break 
                                case 13: 
                                    currentBuild.result = 'ABORTED' 
                                    break 
                                default: 
                                    currentBuild.result = 'NOT_BUILT' 
                                } 
                        }
    }

...