Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use the report plugin on (PMD, PHPCPD, checkstyle, Jdepend...) in a Jenkins pipeline?

I'm using Jenkins 2.x with a Jenkinsfile to run a pipeline.

I have built a job using Jenkinsfile and I want to invoke the Analysis Collector Plugin so I can view the report.

Here is my current Jenkinsfile:

#!groovy

node {

  stage 'Build '
    echo "My branch is: ${env.BRANCH_NAME}"
    sh 'cd gitlist-PHP && ./gradlew clean build dist'

  stage 'Report'
    step([$class: 'JUnitResultArchiver', testResults: 'gitlist-PHP/build/logs/junit.xml'])
    step([$class: 'hudson.plugins.checkstyle.CheckStylePublisher', checkstyle: 'gitlist-PHP/build/logs/phpcs.xml'])
    step([$class: 'hudson.plugins.dry.DryPublisher', CopyPasteDetector: 'gitlist-PHP/build/logs/phpcpd.xml'])

  stage 'mail'
  mail body: 'project build successful',
     from: '[email protected]',
     replyTo: '[email protected]',
     subject: 'project build successful',
     to: '[email protected]'
}

I want to invoke invoke Checkstyle, Junit and DRY plugin from Jenkins. How do I configure these plugins in the Jenkinsfile? Do these plugins support pipelines?

like image 464
Pandu Siregar Avatar asked Jul 25 '16 04:07

Pandu Siregar


1 Answers

The following configuration works for me:

   step([$class: 'CheckStylePublisher', pattern: 'target/scalastyle-result.xml, target/scala-2.11/scapegoat-report/scapegoat-scalastyle.xml'])

For junit configuration is even easier:

junit 'target/test-reports/*.xml'
like image 164
Aliaksandr Kavalevich Avatar answered Sep 18 '22 13:09

Aliaksandr Kavalevich