2017-07-31 76 views
2

在Jenkins(Jenkins 2.6)中设置管道构建,复制基于git的构建的示例脚本给出:“没有找到名为MSBuild的工具”。我已经在Manage Jenkins -> Global Tool Configuration中设置了MSBuild工具。我在从节点上运行管道。

在从站配置中,我在Node Properties -> Tool Locations中设置了MSBuild工具路径。
虽然构建过程中无法获取MSBuild工具路径,如果我运行没有管道的同源(不使用Jenkinsfile),它工作正常。


请参阅Jenkinsfile语法Jenkins:找不到名为MSBuild的工具

pipeline { 
    agent { label 'win-slave-node' } 
    stages { 
      stage('build') { 
      steps { 

      bat "\"${tool 'MSBuild'}\" SimpleWindowsProject.sln /t:Rebuild /p:Configuration=Release" 
      } 
    } 
    } 
} 



我也试图改变环境变量的窗户奴隶它不刷新。


注:我已经安装了MS从节点

+0

你检查过控制台上代理其在你建造的时候正在跑步。 –

+0

您可以检查此一次 “节点( '双赢从属节点'){ 高清的MSBuild 的MSBuild =工具 '的MSBuild' 阶段( '构建'){ 蝙蝠(/” $ {的MSBuild}” SimpleWindowsProject。 sln/t:Rebuild/p:Configuration = Release /) } }“ –

+0

上面是相同的代码,稍作修改尝试一次检查是否工作/不是 –

回答

3

上构建工具,在Declarative Pipeline语法,对于MSBuild的模具是有点笨重。下面是我不得不处理它,使用script块:

pipeline { 
    agent { 
    label 'win-slave-node' 
    } 
    stages { 
    stage('Build') { 
     steps { 
     script { 
      def msbuild = tool name: 'MSBuild', type: 'hudson.plugins.msbuild.MsBuildInstallation' 
      bat "${msbuild} SimpleWindowsProject.sln" 
     } 
     } 
    } 
    } 
} 

在较老的脚本管道的语法,它可能是这样的:

node('win-slave-node') { 
    def msbuild = tool name: 'MSBuild', type: 'hudson.plugins.msbuild.MsBuildInstallation' 

    stage('Checkout') { 
    checkout scm 
    } 

    stage('Build') { 
    bat "${msbuild} SimpleWindowsProject.sln" 
    } 
} 
+0

感谢@nick for上面的解决方案,最后它正在使用msbuild工具,并在命令“bat”\“$ {msbuild} \”SimpleWindowsProject.sln \“中进行小修改。”当我收到**错误**'C:\由于MSBuild路径中的空间,“程序”未被识别为内部或外部命令 –

+1

是的,我们通过使用旧式文件夹名称来避免该特定空间问题,例如,来自Visual Studio 2013的32位MSBuild位于以下位置: C:\ PROGRA〜2 \的MSBuild \ 12.0 \宾\ MSBuild.exe。 –