如何在 Jenkins 中为 Java 配置 Checkstyle 配置
How to Configure a Checkstyle Configuration for Java in Jenkins
我正在尝试从默认的 checkstyle 配置 sun-checks 切换到 google-checks。
在我的 jenkinsfile 中,我写着:
stage('checkstyle') {
steps {
sh "mvn clean checkstyle:checkstyle -Dcheckstyle.config.location='https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml'"
checkstyle canComputeNew: false, defaultEncoding: '', healthy: '', pattern: 'target/checkstyle-result.xml', unHealthy: ''
}
}
失败并显示错误消息
Failed to execute goal
org.apache.maven.plugins:maven-checkstyle-plugin:2.17:checkstyle
(default-cli) on project pmm: An error has occurred in Checkstyle
report generation.: Failed during checkstyle execution: Failed during
checkstyle configuration: unable to parse configuration stream -
Element type "html" must be declared.:8:17 -> [Help 1]
如何更改 Jenkins 的 checkstyle 配置?
https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
首先,您要给它一个 HTML 文档而不是 XML 文件。您必须使用 URL 到 github 的 raw 文件。
示例:https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/main/resources/google_checks.xml
其次,您不应该使用 google_checks 的在线 SNAPSHOT 版本。请参阅 了解原因。
How can I change the checkstyle configuration for Jenkins?
提取在 checkstyle JAR 中找到的配置(如果您要更改它),并让您的 maven 命令改用它。
我正在尝试从默认的 checkstyle 配置 sun-checks 切换到 google-checks。
在我的 jenkinsfile 中,我写着:
stage('checkstyle') {
steps {
sh "mvn clean checkstyle:checkstyle -Dcheckstyle.config.location='https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml'"
checkstyle canComputeNew: false, defaultEncoding: '', healthy: '', pattern: 'target/checkstyle-result.xml', unHealthy: ''
}
}
失败并显示错误消息
Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:checkstyle (default-cli) on project pmm: An error has occurred in Checkstyle report generation.: Failed during checkstyle execution: Failed during checkstyle configuration: unable to parse configuration stream - Element type "html" must be declared.:8:17 -> [Help 1]
如何更改 Jenkins 的 checkstyle 配置?
https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml
首先,您要给它一个 HTML 文档而不是 XML 文件。您必须使用 URL 到 github 的 raw 文件。
示例:https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/main/resources/google_checks.xml
其次,您不应该使用 google_checks 的在线 SNAPSHOT 版本。请参阅
How can I change the checkstyle configuration for Jenkins?
提取在 checkstyle JAR 中找到的配置(如果您要更改它),并让您的 maven 命令改用它。