简体   繁体   English

Jenkins无法运行MSBuild命令

[英]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.

相关问题 在Jenkins目标中运行的Msbuild目标调用HgPull失败,并出现HgProcessException:该命令 <hg.exe> 不可用 - Msbuild running in Jenkins target calling HgPull fails with HgProcessException: The command <hg.exe> is not available MsBuild 在 Jenkins 上失败 - MsBuild Fails on Jenkins Msbuild通过VS和命令行运行,但通过Jenkins失败 - Msbuild works via VS and command-line, but fails via Jenkins 在 kubernetes 集群上使用 docker 命令运行 Jenkins 作业失败“docker:未找到” - Running Jenkins job with docker command on kubernetes cluster fails "docker: not found" 在Windows上运行的Jenkins Release神器作业在Git push命令中失败 - Jenkins Release artifact job running on Windows fails in Git push command 运行 npm install 命令时,Jenkins 构建步骤失败 - Jenkins build step fails when running npm install command 错误 MSB3073:命令“subwcrev.exe 以代码 6 退出。在 Jenkins 上运行 MSBuild - error MSB3073: The command "subwcrev.exe exited with code 6. Running MSBuild on Jenkins 詹金斯批处理命令失败 - Jenkins Batch command Fails Sonarscanner MSBuild 工具未在管道中运行 - Jenkins - Sonarscanner MSBuild tool is not running in pipeline - Jenkins 在jenkins中运行Groovy命令 - Running Groovy command in jenkins
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM