如何获取检出Pipeline Jenkinsfile的文件夹(Jenkins) [英] How to obtain the folder where the Pipeline Jenkinsfile is checked out (Jenkins)

查看:404
本文介绍了如何获取检出Pipeline Jenkinsfile的文件夹(Jenkins)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个大项目(就大小而言),我们正在尝试使用在项目内部进行检查的Jenkinsfile进行构建.

为了节省磁盘空间和构建时间,我们尝试最小化副本数,因此我们要使用检出Jenkinsfile的文件夹,因为该文件夹已经被完全克隆了. /p>

通过手动调查,我已经看到在作业文件夹中创建了一个workspace@script文件夹.那是我想获取的文件夹路径.

我本来希望pwd()能够解决问题,但是由于某些原因,它仅在节点内部起作用,从而解析了该文件夹的路径.

stage "Build"

def scriptWorkspace=??

node {
  sh """
    TERM=xterm ls --color /etc
    set

    docker run ... -v ${scriptWorkspace}:/mercurial-repository ...
  """
}

解决方案

正在实施 JENKINS-33273 用于您正在使用的SCM(在这种情况下,我想是Mercurial?需要使用该插件中的缓存"功能),Jenkinsfile总是在主节点上的专用工作区中检出,脚本本身不可用.

We're having a big project (in terms of size), that we're trying to build using a Jenkinsfile that is checked inside the project itself.

In order to conserve disk space and build times we try to minimize the number of copies, so what we would want is to use the folder where the Jenkinsfile is checked out, since that is already a repo fully cloned.

Manually investigating, I've seen that there is a workspace@script folder created inside the job's folder. That is folder path that I would like to obtain.

I would have expected pwd() to do the trick, but for some reason that works only inside nodes, resolving the path to that folder.

stage "Build"

def scriptWorkspace=??

node {
  sh """
    TERM=xterm ls --color /etc
    set

    docker run ... -v ${scriptWorkspace}:/mercurial-repository ...
  """
}

解决方案

Pending an implementation of JENKINS-33273 for the SCM you are using (Mercurial in this case I suppose? would require use of the "caching" feature in that plugin), Jenkinsfile is always checked out on a private workspace on the master node, not available to the script itself.

这篇关于如何获取检出Pipeline Jenkinsfile的文件夹(Jenkins)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆