How to get build workspace path using jenkins remote api?

2.7k Views Asked by At

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
1

There are 1 best solutions below

0
Pom12 On

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