【问题标题】:Where does the jenkins shared library files get stored?jenkins 共享库文件存储在哪里?
【发布时间】:2017-02-23 21:35:53
【问题描述】:

jenkins 中的共享库文件是在作业开始时加载的,存放在哪里?我正在尝试访问存储在共享库中的 dockerfile,我需要在 docker build 命令中提供路径。有没有办法在jenkins中找到共享库文件的加载位置?

【问题讨论】:

    标签: jenkins jenkins-plugins jenkins-pipeline


    【解决方案1】:

    如果共享库是从 SCM 加载的,并且您的工作区路径是 jenkins/workspaces/jobName,则将副本检出到 jenkins/workspaces/jobName@libs 或类似名称(如果该路径被另一个并发构建占用,则可能带有数字后缀)。

    但是,there is another way,如果我理解正确,您不想在这个库中检索资源吗?在这种情况下,您应该使用libraryResourcewriteFile 步骤。像这样:

    writeFile file:'myFile.txt', text:libraryResource("path/to/myFile.txt")
    

    【讨论】:

    • 我应该在 libraryResource 中使用什么路径? text:libraryResource("path/to/myFile.txt") 如何在我的资源中找到文件的路径?你能说得清楚一点吗?
    • 看这里,jenkins.io/doc/book/pipeline/shared-libraries/…,基本上,如果你在你的仓库中,有你的文件在resources/path/to/myFile.txt 然后你使用libraryResource("path/to/myFile.txt")。例如。这些文件是相对于resources/ 文件夹解析的。
    • jenkins 节点上 myFile.txt 的位置在哪里?
    • @codeGeass 你指的是 {{writeFile file:'myFile.txt' ...}} 然后文件被写入当前工作目录。
    • 是的,在工作区?找不到,所以我写了 {writeFile file:"${WORKSPACE}/myFile.txt" ...}
    猜你喜欢
    • 1970-01-01
    • 2011-09-03
    • 2019-10-03
    • 1970-01-01
    • 1970-01-01
    • 2018-02-23
    • 2022-08-17
    • 1970-01-01
    相关资源
    最近更新 更多