詹金斯蓝海工作区路径太长

时间:2017-05-19 09:54:07

标签: windows jenkins .net-core jenkins-pipeline jenkins-blueocean

我们正在使用Jenkins Blue Ocean在Windows 2012 r2 Jenkins Slaves上构建.Net应用程序。我们在git repos中使用Jenkinsfile来定义构建管道。

由于工作区构建路径太长而Windows无法处理,因此有几个项目导致构建失败 这通常发生在最大路径最大的nuget packnpm install命令中。

The specified path, file name, or both are too long. 
The fully qualified file name must be less than 260 characters, 
and the directory name must be less than 248 characters.

script returned exit code 1

由于我们不能影响Visual Studio Solution nuget包路径的长度,我们如何将工作区文件夹放到Windows可以处理的内容中?

感谢Mutsa的建议,这是我们在Jenkins文件中的最终结果:

pipeline {
agent {
    node {
        label 'win'
        customWorkspace "ws\\${JOB_NAME.replace("%2F", "_")}"
    }
}

可以在GitHub上的.net核心Wakeboard UK website repo的上下文中看到。

2 个答案:

答案 0 :(得分:3)

对于声明性管道,使用 customworksace 选项覆盖节点,docker或dockerfile部分中的默认路径。见例。

agent {
node {
    customWorkspace '/some/other/path'
}

它可以是相对于工作空间根或绝对路径的相对路径。

答案 1 :(得分:0)

您始终可以自定义工作区路径并指向目录