[英]Jenkins fails running MSBuild command
This is my Jenkinsfile, and I have MSBuild plugin installed in Jenkins. 这是我的Jenkinsfile,并且我在Jenkins中安装了MSBuild插件。 The msbuild command below is correct as I can run it from the command line, yet Jenkins keeps failing on it.
下面的msbuild命令是正确的,因为我可以从命令行运行它,但是Jenkins一直在失败。 If I remove the parameter it's complaining about then it fails on next one, etc...
如果我删除它抱怨的参数,那么它将在下一个失败,等等。
Jenkinsfile (saved in git repository): Jenkinsfile(保存在git仓库中):
pipeline {
agent {
docker 'node:7.7.3'
}
stages {
stage('Build') {
steps {
bat echo 'Checking node.js version..'
bat echo 'node -v'
bat echo 'Restore nugets..'
bat 'nuget restore mySolution.sln'
bat echo 'Building..'
bat "C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\msbuild.exe" mySolution.sln /noautorsp /ds /nologo /t:clean,rebuild /p:Configuration=Debug /v:m /p:VisualStudioVersion=14.0 /clp:Summary;ErrorsOnly;WarningsOnly /p:ProductVersion=1.0.0.${env.BUILD_NUMBER}
}
}
stage('Test') {
steps {
bat echo 'Testing..'
}
}
stage('Deploy') {
steps {
bat echo 'Deploying....'
}
}
}
post {
success {
bat echo 'Pipeline Succeeded'
}
failure {
bat echo 'Pipeline Failed'
}
unstable {
bat echo 'Pipeline run marked unstable'
}
}
}
Error: 错误:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 14: expecting '}', found '/' @ line 14, column 84.
\msbuild.exe" mySolution.sln /noautorsp
^
The issue is that the entire bat
argument needs to be in quotes, so: 问题在于,整个
bat
参数都需要用引号引起来,因此:
bat "'C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\msbuild.exe' mySolution.sln /noautorsp /ds /nologo /t:clean,rebuild /p:Configuration=Debug /v:m /p:VisualStudioVersion=14.0 /clp:Summary;ErrorsOnly;WarningsOnly /p:ProductVersion=1.0.0.${env.BUILD_NUMBER}"
Otherwise, it's treating mySolution.sln
as a Groovy keyword, then /noautorsp
, etc. You could also avoid the full path to MSBuild.exe here by defining it as a tool in Jenkins (via the MSBuild plugin ), then doing what I describe at https://stackoverflow.com/a/45592810/466874 . 否则,它将
mySolution.sln
当作Groovy关键字,然后将/noautorsp
等/noautorsp
。您还可以通过在Jenkins中将其定义为工具(通过MSBuild插件 )来避免MSBuild.exe的完整路径,然后按照我的描述进行操作在https://stackoverflow.com/a/45592810/466874中 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.