Atu*_*l N 7 msbuild jenkins jenkins-slave jenkins-pipeline
在Jenkins(Jenkins 2.6)中设置Pipeline构建,复制基于git的构建的示例脚本给出:"没有找到名为MSBuild的工具".我已经设置了MSBuild工具Manage Jenkins -> Global Tool Configuration.我在从节点上运行管道.
在Slave配置中,我已经设置了MSBuild工具路径Node Properties -> Tool Locations.
在构建过程中,它无法获得MSBuild工具路径,如果我在没有管道的情况下运行相同的源(不使用Jenkinsfile),它可以正常工作.
请参阅Jenkinsfile语法
pipeline {
agent { label 'win-slave-node' }
stages {
stage('build') {
steps {
bat "\"${tool 'MSBuild'}\" SimpleWindowsProject.sln /t:Rebuild /p:Configuration=Release"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我也尝试更改windows slave的环境变量,它没有刷新.
注意:我已在从属节点上安装了MS Build工具
Nic*_*nes 12
在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"
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
在较旧的Scripted Pipeline语法中,它可能是这样的:
node('win-slave-node') {
def msbuild = tool name: 'MSBuild', type: 'hudson.plugins.msbuild.MsBuildInstallation'
stage('Checkout') {
checkout scm
}
stage('Build') {
bat "${msbuild} SimpleWindowsProject.sln"
}
}
Run Code Online (Sandbox Code Playgroud)
您必须在 Jenkins => 管理 Jenkins => 全局工具配置中定义 MSBuild 或使用已定义的不同工具名称。
${tool 'toolname'} returns the path defined for a tool in Global Tool Configuration.
Run Code Online (Sandbox Code Playgroud)
警告:注意定义的路径。它是否指向文件夹或 msbuild.exe?您可能必须附加 msbuild.exe:
${tool 'VS2017'}\msbuild.exe
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7069 次 |
| 最近记录: |