Reputation: 1711
I have written some bash scripts for some specific project based automation. I am using the Parameterized Build process for uploading a file as explained in this SO link. The issue is that I need to access the uploaded file from the scripts, but I am unaware of the location its been placed after upload.
Jenkins hints that the location would be relative to the workspace. I am not sure of what the workspace, in terms of Jenkins means. I tried a couple of options.. the trunk location, /users/$USER/workspace/, /users/$USER/workspace/[project_name]/
Could anyone help me with the same?
Thanks in advance.
Upvotes: 2
Views: 5163
Reputation: 4075
The Workspace is usually under the 'jenkins' folder, separated by job-names.
To find the exact location of your job's Workspace,
simply echo the value of that parameter in your job:echo $WORKSPACE
(for Unix/Linux/Mac)echo %WORKSPACE%
(for Windows)
To use this location in your scripts, simply prepend it to the path of your file:ls -l $WORKSPACE/myFile.txt
ordir %WORKSPACE%\myFile.txt
Note it gets a bit tricky if you try to access the results of Job_AA from Job_BB,
as each is sitting in a different Workspace.
(You can access the Workspace of other jobs, but now Job_BB is dependent on the Name of Job_AA,
which is bad.)
For that I suggest using a shared location for all build-results, outside of Jenkins.
Good luck!
Upvotes: 3
Reputation: 21130
Jenkins assumes that the path to the uploaded file will be prepended by the path to your build's workspace. You can specify your file location as either $WORKSPACE/path/to/file
(Jenkins populates $WORKSPACE with the appropriate path for each build) or just path/to/file
Upvotes: 1