Jenkins:找不到名为 MSBuild 的工具 [英] Jenkins: no tool named MSBuild found
问题描述
在 Jenkins (Jenkins 2.6) 中设置流水线构建,复制基于 git 的构建的示例脚本会给出:找不到名为 MSBuild 的工具".我在 Manage Jenkins -> 中设置了 MSBuild Tool全局工具配置
.我在从节点上运行管道.
在Slave配置中,我在Node Properties ->中设置了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 工具
推荐答案
在 声明式管道 语法,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屋!