首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在(PMD、PHPCPD、checkstyle、Jdepend...)上使用报告插件在Jenkins管道里?

如何在(PMD、PHPCPD、checkstyle、Jdepend...)上使用报告插件在Jenkins管道里?
EN

Stack Overflow用户
提问于 2016-07-25 12:21:07
回答 4查看 10.2K关注 0票数 11

我正在使用带有Jenkinsfile的Jenkins 2.x来运行管道。

我已经使用Jenkinsfile构建了一个作业,并且我想调用Analysis Collector插件,以便可以查看报告。

这是我当前的Jenkinsfile:

代码语言:javascript
复制
#!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: 'siregarpandu@gmail.com',
     replyTo: 'xxxx@yyyy.com',
     subject: 'project build successful',
     to: 'siregarpandu@gmail.com'
}

我想从Jenkins调用invoke Checkstyle,Junit和DRY插件。如何在Jenkinsfile中配置这些插件?这些插件支持管道吗?

EN

回答 4

Stack Overflow用户

发布于 2017-01-13 00:57:46

以下配置适用于我:

代码语言:javascript
复制
   step([$class: 'CheckStylePublisher', pattern: 'target/scalastyle-result.xml, target/scala-2.11/scapegoat-report/scapegoat-scalastyle.xml'])

对于junit,配置甚至更简单:

代码语言:javascript
复制
junit 'target/test-reports/*.xml'
票数 7
EN

Stack Overflow用户

发布于 2016-09-05 12:43:24

代码语言:javascript
复制
step([$class: 'hudson.plugins.checkstyle.CheckStylePublisher', checkstyle: 'gitlist-PHP/build/logs/phpcs.xml'])

同样根据源代码存储库,参数'checkstyle‘应该命名为'pattern’。

存储库:https://github.com/jenkinsci/checkstyle-plugin/blob/master/src/main/java/hudson/plugins/checkstyle/CheckStylePublisher.java#L42

票数 5
EN

Stack Overflow用户

发布于 2017-10-12 19:39:04

我是这样处理这个问题的:

PMD

代码语言:javascript
复制
stage('PMD') {
    steps {
        sh 'vendor/bin/phpmd . xml build/phpmd.xml --reportfile build/logs/pmd.xml --exclude vendor/ || exit 0'
        pmd canRunOnFailed: true, pattern: 'build/logs/pmd.xml'
    }
}

PHPCPD

代码语言:javascript
复制
stage('Copy paste detection') {
    steps {
        sh 'vendor/bin/phpcpd --log-pmd build/logs/pmd-cpd.xml --exclude vendor . || exit 0'
        dry canRunOnFailed: true, pattern: 'build/logs/pmd-cpd.xml'
    }
}

检查样式

代码语言:javascript
复制
stage('Checkstyle') {
    steps {
        sh 'vendor/bin/phpcs --report=checkstyle --report-file=`pwd`/build/logs/checkstyle.xml --standard=PSR2 --extensions=php --ignore=autoload.php --ignore=vendor/ . || exit 0'
        checkstyle pattern: 'build/logs/checkstyle.xml'
    }
}

JDepend

代码语言:javascript
复制
stage('Software metrics') {
    steps {
        sh 'vendor/bin/pdepend --jdepend-xml=build/logs/jdepend.xml --jdepend-chart=build/pdepend/dependencies.svg --overview-pyramid=build/pdepend/overview-pyramid.svg --ignore=vendor .'
    }
}

您可以在此处找到完整的示例:https://gist.github.com/Yuav/435f29cad03bf0006a85d31f2350f7b4

参考链接

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38559665

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档