This is my Jenkinsfile, and I have MSBuild plugin installed in Jenkins. The msbuild command below is correct as I can run it from the command line, yet Jenkins keeps failing on it. If I remove the parameter it's complaining about then it fails on next one, etc...
Jenkinsfile (saved in git repository):
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 "'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 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.