在Jenkins(Jenkins 2.6)中设置Pipeline构建,复制基于git的构建的示例脚本给出:"no tool named MSBuild found" . 我在 Manage Jenkins -> Global Tool Configuration
中设置了MSBuild工具 . 我在从节点上运行管道 .
在Slave配置中,我在 Node Properties -> Tool Locations
中设置了MSBuild工具路径 .
在构建过程中,它无法获得MSBuild工具路径,如果我在没有管道的情况下运行相同的源(不使用Jenkinsfile),它可以正常工作 .
请参阅Jenkinsfile语法
pipeline {
agent { label 'win-slave-node' }
stages {
stage('build') {
steps {
bat "\"${tool 'MSBuild'}\" SimpleWindowsProject.sln /t:Rebuild /p:Configuration=Release"
}
}
}
}
我也尝试更改windows slave的环境变量,它没有刷新 .
NOTE: I have installed MS Build tool for on slave node
3 回答
在Declarative Pipeline语法中,MSBuild的工具有点笨拙 . 这里's how I' ve必须使用
script
块来处理它:在较旧的Scripted Pipeline语法中,它可能是这样的:
虽然提供的答案肯定有效,但您只需提供正确的完整工具名称即可 .
在我们的安装中,我们有三种不同的MSBuild版本,我可以使用以下内容
${tool 'MSBuild 15.0 [32bit]'}
对于遇到此问题的任何人,只是想弄清楚Jenkins中的“工具”代码以及配置位置,请参阅以下屏幕截图:
转到管理Jenkins - >全局工具配置:
向下滚动到MSBuild并单击按钮以展开该部分:
Here you can see what tool name to use to reference MSBuild (或添加一个):
然后您可以引用它,例如:
bat "\"${tool '15.0'}\" solution.sln /p:Configuration=Release /p:Platform=\"x86\"
(示例不是声明性语法,但应该显示该想法)