Jenkins:找不到名为MSBuild的工具 [英] Jenkins: no tool named MSBuild found

查看:674
本文介绍了Jenkins:找不到名为MSBuild的工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Jenkins(Jenkins 2.6)中设置管道构建,复制基于git的构建的示例脚本会得到:找不到名为MSBuild的工具".我已经在Manage Jenkins -> Global Tool Configuration中设置了MSBuild工具.我正在从属节点上运行管道.

在从配置中,我在Node Properties -> Tool Locations中设置了MSBuild工具路径.
在构建过程中,它无法获取MSBuild工具路径,如果我在不使用管道的情况下运行相同的源代码(不使用Jenkinsfile),则可以正常工作.


请参阅Jenkinsfile语法

Setting up a Pipeline build in Jenkins (Jenkins 2.6), copying the sample script for a git-based build gives: "no tool named MSBuild found". I have set MSBuild Tool in Manage Jenkins -> Global Tool Configuration. I am running pipeline on the slave node.

In Slave configuration, I have set MSBuild tool path in Node Properties -> Tool Locations.
While build process it is not able to get MSBuild tool path, if i run same source without pipeline (without using Jenkinsfile) it works fine.


Please see Jenkinsfile Syntax

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

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



我也尝试为未刷新的Windows slave更改环境变量.


注意:我已经在从属节点上安装了MS Build工具



I have also tried to change environment variable for windows slave it not refreshed.


NOTE: I have installed MS Build tool for on slave node

推荐答案

声明性管道语法,MSBuild的工具有点笨拙.这是我必须使用script块处理的方式:

In Declarative Pipeline syntax, the tooling for MSBuild is a little clunkier. Here's how I've had to handle it, using a script block:

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

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

In the older Scripted Pipeline syntax, it could be like this:

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

  stage('Checkout') {
    checkout scm
  }

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

这篇关于Jenkins:找不到名为MSBuild的工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆