如何在Jenkins流水线中获取{env.WORKSPACE}的父目录

huangapple go评论58阅读模式
英文:

How to fetch parent directory of {env.WORKSPACE } in jenkins pipeline

问题

你好,我有一个需求,需要获取工作空间父目录的路径。如何做到这一点?

英文:

Hi have a requirement to fetch the path of the parent directory of the work space. How can do that?

答案1

得分: 2

你可以在Linux中使用${WORKSPACE}/..,在Windows中使用%WORKSPACE%/..

如果你想将其获取到变量中,可以运行类似以下的命令:

path=$(cd ${WORKSPACE}/.. && pwd)
英文:

You can use ${WORKSPACE}/.. for linux or %WORKSPACE%/.. for Windows.

If you want to fetch it to variable, you can run something like:

path=$(cd ${WORKSPACE}/.. && pwd)

huangapple
  • 本文由 发表于 2020年3月16日 14:02:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/60701039.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定