我正在使用带有Jenkinsfile的Jenkins 2.x来运行管道。
我已经使用Jenkinsfile构建了一个作业,并且我想调用Analysis Collector插件,以便可以查看报告。
这是我当前的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: 'siregarpandu@gmail.com',
replyTo: 'xxxx@yyyy.com',
subject: 'project build successful',
to: 'siregarpandu@gmail.com'
}我想从Jenkins调用invoke Checkstyle,Junit和DRY插件。如何在Jenkinsfile中配置这些插件?这些插件支持管道吗?
发布于 2017-01-13 00:57:46
以下配置适用于我:
step([$class: 'CheckStylePublisher', pattern: 'target/scalastyle-result.xml, target/scala-2.11/scapegoat-report/scapegoat-scalastyle.xml'])对于junit,配置甚至更简单:
junit 'target/test-reports/*.xml'发布于 2016-09-05 12:43:24
step([$class: 'hudson.plugins.checkstyle.CheckStylePublisher', checkstyle: 'gitlist-PHP/build/logs/phpcs.xml'])同样根据源代码存储库,参数'checkstyle‘应该命名为'pattern’。
发布于 2017-10-12 19:39:04
我是这样处理这个问题的:
PMD
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
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'
}
}检查样式
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
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
参考链接
https://stackoverflow.com/questions/38559665
复制相似问题