无法使用下一代警告访问 Jenkins 管道中的 recordIssues
Cannot access recordIssues in Jenkins Pipeline using Warnings Next Generation
我有一个带有 recordIssues 步骤的简单 Jenkinsfile。相关代码如下所示:
step([
$class: 'recordIssues',
aggregatingResults: true,
enabledForFailure: true,
tools: [pyLint()]
])
我已经安装了最新版本的 Warnings Next Generation 插件 (https://plugins.jenkins.io/warnings-ng),但我 运行 遇到了以下问题:
[Pipeline] step
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
java.lang.UnsupportedOperationException: no known implementation of interface jenkins.tasks.SimpleBuildStep is named recordIssues
at org.jenkinsci.plugins.structs.describable.DescribableModel.resolveClass(DescribableModel.java:478)
是否可以通过某种方式检查扩展是否安装正确?
这对我有用(Jenkins 版本 2.164.1):
stage('Static Analysis') {
recordIssues(
tool: pyLint(pattern: '**/pylint.out'),
unstableTotalAll: '100',
)
recordIssues(
tool: pep8(pattern: '**/pep8.out'),
unstableTotalAll: '100',
)
}
这是我在 Jenkins 中用于 Python 项目 CI 配置的工作版本,以使用 JUnit、PEP8、Pylint 和覆盖率报告:
...
stage('Test: Run') {
steps {
// Run my project tests.
sh 'coverage run manage.py tests'
// Dump coverage metrics to XML.
sh 'coverage xml'
// Run Pylint.
sh 'pylint --rcfile=.pylintrc my_project > reports/pylint.report'
// Run Pycodestyle (PEP8 checks).
sh 'pycodestyle my_project > reports/pep8.report'
}
post {
always{
// Generate JUnit, PEP8, Pylint and Coverage reports.
junit 'reports/*junit.xml'
recordIssues(
tool: pep8(pattern: 'reports/pep8.report'),
unstableTotalAll: 200,
failedTotalAll: 220
)
recordIssues(
tool: pyLint(pattern: 'reports/pylint.report'),
unstableTotalAll: 20,
failedTotalAll: 30
)
cobertura coberturaReportFile: 'reports/coverage.xml'
}
}
}
...
适用于 Cobertura plugin, JUnit plugin and Warnings Next Generation. Python packages I used are the traditional coverage and pylint and for PEP8 I used pycodestyle。
希望这对其他人有所帮助,因为找到这方面的好例子 Jenkinsfile
并不容易。
仅作记录:
詹金斯 v2.204.2
Jenkins 警告下一代插件 v8.0.0
stage('Static Analysis') {
steps {
recordIssues(
tool: pyLint(pattern: '**/pylint.out'),
unstableTotalAll: 100,
)
}
我有一个带有 recordIssues 步骤的简单 Jenkinsfile。相关代码如下所示:
step([
$class: 'recordIssues',
aggregatingResults: true,
enabledForFailure: true,
tools: [pyLint()]
])
我已经安装了最新版本的 Warnings Next Generation 插件 (https://plugins.jenkins.io/warnings-ng),但我 运行 遇到了以下问题:
[Pipeline] step
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
java.lang.UnsupportedOperationException: no known implementation of interface jenkins.tasks.SimpleBuildStep is named recordIssues
at org.jenkinsci.plugins.structs.describable.DescribableModel.resolveClass(DescribableModel.java:478)
是否可以通过某种方式检查扩展是否安装正确?
这对我有用(Jenkins 版本 2.164.1):
stage('Static Analysis') {
recordIssues(
tool: pyLint(pattern: '**/pylint.out'),
unstableTotalAll: '100',
)
recordIssues(
tool: pep8(pattern: '**/pep8.out'),
unstableTotalAll: '100',
)
}
这是我在 Jenkins 中用于 Python 项目 CI 配置的工作版本,以使用 JUnit、PEP8、Pylint 和覆盖率报告:
...
stage('Test: Run') {
steps {
// Run my project tests.
sh 'coverage run manage.py tests'
// Dump coverage metrics to XML.
sh 'coverage xml'
// Run Pylint.
sh 'pylint --rcfile=.pylintrc my_project > reports/pylint.report'
// Run Pycodestyle (PEP8 checks).
sh 'pycodestyle my_project > reports/pep8.report'
}
post {
always{
// Generate JUnit, PEP8, Pylint and Coverage reports.
junit 'reports/*junit.xml'
recordIssues(
tool: pep8(pattern: 'reports/pep8.report'),
unstableTotalAll: 200,
failedTotalAll: 220
)
recordIssues(
tool: pyLint(pattern: 'reports/pylint.report'),
unstableTotalAll: 20,
failedTotalAll: 30
)
cobertura coberturaReportFile: 'reports/coverage.xml'
}
}
}
...
适用于 Cobertura plugin, JUnit plugin and Warnings Next Generation. Python packages I used are the traditional coverage and pylint and for PEP8 I used pycodestyle。
希望这对其他人有所帮助,因为找到这方面的好例子 Jenkinsfile
并不容易。
仅作记录: 詹金斯 v2.204.2 Jenkins 警告下一代插件 v8.0.0
stage('Static Analysis') {
steps {
recordIssues(
tool: pyLint(pattern: '**/pylint.out'),
unstableTotalAll: 100,
)
}