2017-04-04 23 views
0

これは私のJenkinsfileです.JenkinsにはMSBuildプラグインがインストールされています。以下のmsbuildコマンドは、コマンドラインから実行できるので正しいですが、Jenkinsはそれに失敗し続けます。私は、パラメータを削除した場合、それは文句だ、それはなど、次のいずれかに障害が発生した...JenkinsはMSBuildコマンドの実行に失敗します

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' 
     }  
    } 
} 

エラー:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: 
WorkflowScript: 14: expecting '}', found '/' @ line 14, column 84. 
    \msbuild.exe" mySolution.sln /noautorsp 
           ^
+0

スラッシュをエスケープする必要があります。行14の完全なコマンドの回りに一重引用符を入れてみることはできますか?このように:bat 'command' –

+0

同じ問題があります。 – Ninos

答えて

0

問題があります全体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}" 

そうでなければ、それはトリートですGroovyのキーワードとしてmySolution.slnを指定してから/noautorspなどに変更することができます。また、MSBuild.exeのフルパスをJenkinsのツール(MSBuild plugin経由)として定義してから、https://stackoverflow.com/a/45592810/466874で説明します。

関連する問題