WarningsPlugin不从MSBuild收集警告(WarningsPlugin not Collecting warnings from MSBuild)

我正在尝试Multibranch工作。 构建解决方案有效,但解析构建生成的警告失败。

这是我的Jenkinsfile:

node { stage ('Checkout') { checkout scm } stage ('Build') { bat "\"${tool 'MSBuild VS2013'}\" Solution.sln /p:Configuration=Release /p:Platform=\"Any CPU\" /p:ProductVersion=1.0.0.${env.BUILD_NUMBER}" } stage ('Warnings') { step([$class: 'WarningsPublisher', canComputeNew: false, canResolveRelativePaths: false, defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', parserConfigurations: [[parserName: 'MSBuild']], unHealthy: '']) } }

我从警告插件中得到此异常:

Projekt : Das Einlesen der Datei d:\jenkins20\configs\workspace\JenkinsFile_master-CQILFOMT634B5TYN4BWJKVHYYWABZMZHXNE4WK5BQE2E2MJN4MDQ ist wegen folgender Exception fehgeschlagen: java.io.FileNotFoundException: d:\jenkins20\configs\workspace\JenkinsFile_master-CQILFOMT634B5TYN4BWJKVHYYWABZMZHXNE4WK5BQE2E2MJN4MDQ (Zugriff verweigert) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(Unknown Source) at java.io.FileInputStream.<init>(Unknown Source) at hudson.plugins.warnings.parser.ParserRegistry.createReader(ParserRegistry.java:325) at hudson.plugins.warnings.parser.ParserRegistry.parse(ParserRegistry.java:281) at hudson.plugins.warnings.parser.ParserRegistry.parse(ParserRegistry.java:261) at hudson.plugins.warnings.parser.FileWarningsParser.parse(FileWarningsParser.java:44) at hudson.plugins.analysis.core.FilesParser.parseFile(FilesParser.java:325) at hudson.plugins.analysis.core.FilesParser.parseFiles(FilesParser.java:283) at hudson.plugins.analysis.core.FilesParser.parseSingleFile(FilesParser.java:241) at hudson.plugins.analysis.core.FilesParser.invoke(FilesParser.java:200) at hudson.plugins.analysis.core.FilesParser.invoke(FilesParser.java:31) at hudson.FilePath.act(FilePath.java:996) at hudson.FilePath.act(FilePath.java:974) at hudson.plugins.warnings.WarningsPublisher.parseFiles(WarningsPublisher.java:392) at hudson.plugins.warnings.WarningsPublisher.perform(WarningsPublisher.java:290) at hudson.plugins.analysis.core.HealthAwarePublisher.perform(HealthAwarePublisher.java:68) at hudson.plugins.analysis.core.HealthAwareRecorder.perform(HealthAwareRecorder.java:295) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:69) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:59) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47) at hudson.security.ACL.impersonate(ACL.java:221) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

I am experimenting with a Multibranch job. Building the solution works, but parsing the warnings generated by the build fails.

this is my Jenkinsfile:

node { stage ('Checkout') { checkout scm } stage ('Build') { bat "\"${tool 'MSBuild VS2013'}\" Solution.sln /p:Configuration=Release /p:Platform=\"Any CPU\" /p:ProductVersion=1.0.0.${env.BUILD_NUMBER}" } stage ('Warnings') { step([$class: 'WarningsPublisher', canComputeNew: false, canResolveRelativePaths: false, defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', parserConfigurations: [[parserName: 'MSBuild']], unHealthy: '']) } }

I get this Exception from the Warnings Plugin:

Projekt : Das Einlesen der Datei d:\jenkins20\configs\workspace\JenkinsFile_master-CQILFOMT634B5TYN4BWJKVHYYWABZMZHXNE4WK5BQE2E2MJN4MDQ ist wegen folgender Exception fehgeschlagen: java.io.FileNotFoundException: d:\jenkins20\configs\workspace\JenkinsFile_master-CQILFOMT634B5TYN4BWJKVHYYWABZMZHXNE4WK5BQE2E2MJN4MDQ (Zugriff verweigert) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(Unknown Source) at java.io.FileInputStream.<init>(Unknown Source) at hudson.plugins.warnings.parser.ParserRegistry.createReader(ParserRegistry.java:325) at hudson.plugins.warnings.parser.ParserRegistry.parse(ParserRegistry.java:281) at hudson.plugins.warnings.parser.ParserRegistry.parse(ParserRegistry.java:261) at hudson.plugins.warnings.parser.FileWarningsParser.parse(FileWarningsParser.java:44) at hudson.plugins.analysis.core.FilesParser.parseFile(FilesParser.java:325) at hudson.plugins.analysis.core.FilesParser.parseFiles(FilesParser.java:283) at hudson.plugins.analysis.core.FilesParser.parseSingleFile(FilesParser.java:241) at hudson.plugins.analysis.core.FilesParser.invoke(FilesParser.java:200) at hudson.plugins.analysis.core.FilesParser.invoke(FilesParser.java:31) at hudson.FilePath.act(FilePath.java:996) at hudson.FilePath.act(FilePath.java:974) at hudson.plugins.warnings.WarningsPublisher.parseFiles(WarningsPublisher.java:392) at hudson.plugins.warnings.WarningsPublisher.perform(WarningsPublisher.java:290) at hudson.plugins.analysis.core.HealthAwarePublisher.perform(HealthAwarePublisher.java:68) at hudson.plugins.analysis.core.HealthAwareRecorder.perform(HealthAwareRecorder.java:295) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:69) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:59) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47) at hudson.security.ACL.impersonate(ACL.java:221) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

最满意答案

通过将msbuild的输出写入Textfile然后使用此文件作为warnings插件的输入来解决问题

stage ('Checkout') { checkout scm } stage ('Build') { bat "\"${tool 'MSBuild VS2013'}\" Solution.sln /p:Configuration=Release /p:Platform=\"Any CPU\" /p:ProductVersion=1.0.0.${env.BUILD_NUMBER} > msbuild.log 2>&1" bat " type msbuild.log" } stage ('Warnings') { step([$class: 'WarningsPublisher', canComputeNew: false, canResolveRelativePaths: false, defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', parserConfigurations: [[parserName: 'MSBuild', pattern: 'msbuild.log']], unHealthy: '']) }

Solved the problem by writing the output from msbuild to a Textfile and then using this file as input for the warnings plugin

stage ('Checkout') { checkout scm } stage ('Build') { bat "\"${tool 'MSBuild VS2013'}\" Solution.sln /p:Configuration=Release /p:Platform=\"Any CPU\" /p:ProductVersion=1.0.0.${env.BUILD_NUMBER} > msbuild.log 2>&1" bat " type msbuild.log" } stage ('Warnings') { step([$class: 'WarningsPublisher', canComputeNew: false, canResolveRelativePaths: false, defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', parserConfigurations: [[parserName: 'MSBuild', pattern: 'msbuild.log']], unHealthy: '']) }

更多推荐