我正在尝试多分支工作。构建解决方案是可行的,但是解析由构建生成的警告会失败。
这是我的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)
通过将msbuild的输出写入文本文件,然后将此文件用作警告插件的输入来解决此问题
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: '']) }