如何使用Jenkins远程API获取构建工作区路径? [英] How to get build workspace path using jenkins remote api?

查看:122
本文介绍了如何使用Jenkins远程API获取构建工作区路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用jenkins远程api获取当前构建的工作空间路径?我可以使用api/json获取基于内部版本号的内部版本详细信息,但它不会返回工作区详细信息.

Is it possible to get current build's workspace path using jenkins remote api? I can get a build details based on build number with api/json, but it doesn't return the workspace details.

curl http://jenkinsServer:8080/job/testing/1/api/json

推荐答案

据我了解,您不能使用Jenkins远程API来做到这一点.但是,您可以从您的项目名称推断工作区.例如,如果Jenkins的基本工作空间是/var/lib/jenkins/workspace (在Unix上默认安装就是这种情况),则您项目的工作空间应该简单地是:

As far as I know you can't do that using Jenkins remote API. However, you can probably infer the workspace from your project name. If, say, Jenkins base workspace is /var/lib/jenkins/workspace (which is the case with default install on Unix), the workspace for your project should simply be :

/var/lib/jenkins/workspace/your-project

这可能足以满足您的需求,但是工作空间可能会有所不同,特别是如果您在管道中签出其他仓库(或从基本脚本中加载其他管道脚本)时,您可能会注意到以下文件夹::

That could be sufficient for your needs, but workspace may vary, in particular if you are checking out some other repo inside your pipeline (or loading some other pipeline script from your base script), you could notice folders such as :

/var/lib/jenkins/workspace/your-project@tmp
/var/lib/jenkins/workspace/your-project@script

这篇关于如何使用Jenkins远程API获取构建工作区路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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