我们正在使用 Jenkins Blue Ocean 在 Windows 2012 r2 Jenkins Slaves 上构建 .Net 应用程序。我们在 git 存储库中使用 Jenkinsfile
来定义构建管道。
由于工作区构建路径太长,Windows 无法处理,我们的几个项目构建失败。
这通常发生在 nuget pack
和 npm 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 解决方案 nuget 包路径的长度,我们如何将工作区文件夹降低到 Windows 可以处理的程度?
感谢 Mutsa 的建议,这是我们在 Jenkinsfile 中的最终结果:
pipeline {
agent {
node {
label 'win'
customWorkspace "ws\\${JOB_NAME.replace("%2F", "_")}"
}
}
可以在我们的 .net 核心中的上下文中看到 Wakeboard UK website repo在 GitHub 上。
最佳答案
对于声明性管道,使用 customworksace 选项覆盖节点、docker 或 dockerfile 部分中的默认路径。参见示例。
agent {
node {
customWorkspace '/some/other/path'
}
它可以是相对于工作区根目录的相对路径,也可以是绝对路径。
关于windows - Jenkins Blue Ocean 工作区路径太长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44066894/