标题翻译
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)
专注分享java语言的经验与见解,让所有开发者获益!
评论