Humm, that would be hard and security unwise. The executing node path 
aren't available to the web. If you are on a secure local network and you 
really want to go down that road, you need to 

   1. mount the slave nodes into the master node local path that would be 
   accessible by the jenkins web process. 
   2. You need to expose those path to the web master node (this is a 
   security breach). 
   3. You would have to make relative path from the node, then recreate the 
   path to the web local web path.

I think it would be easier to just gather artifacts and make them available 
to jenkins results. 

Example from the number above:
slave node (SLAVE1) path: /myjenkinsworkspace/projectA/MyPathIWant
master node mount (do this for every slave node you need): 
$SLAVE1:/myjenkinsworkspace /MyJenkinsSlaveAccess/Slave1
Expose the whole /MyJenkinsSlaveAccess/ to the Jenkins web (this is a huge 
security breach), depend how you serve the jenkins to the web, configure 
the share (build in, ngix, apache...)
then convert the MyPathIWant to a valid jenkins url:
/myjenkinsworkspace/projectA/MyPathIWant --> 
http://myjenkins/MyJenkinsSlaveAccess/Salve1/MyPathIWant

That would work, but I would not recommand that.
On Monday, September 13, 2021 at 11:28:11 AM UTC-4 davidmic...@gmail.com 
wrote:

> Thanks for the reply, but I think you've misunderstood the problem.  
> Getting, using, and publishing the filesystem path to the file is not a 
> problem. What I need to do is create a functional url to that file, which I 
> can print in the Jenkins build output, which a user can click to get to 
> that file.
>
> On Monday, September 13, 2021 at 6:40:56 AM UTC-7 jerome.god...@gmail.com 
> wrote:
>
>> Some helper I made for my scripted:
>>
>> Path conversion:
>> *def ToWindowsPath(path) {*
>> *return path.replace("/", "\\");*
>> *}*
>>
>> *def ToUnixPath(path) {*
>> *return path.replace("\\","/");*
>> *}*
>>
>> *def ToNativePath(path) {*
>> *if(isUnix()) {*
>> *return ToUnixPath(path);*
>> * }*
>> *return ToWindowsPath(path);*
>> *}*
>>
>> *def RemoveLastChar(str) {*
>> *return str.substring(0, str.length() - 1);*
>> *}*
>>
>> *def RemoveFirstChar(str) {*
>> *return str.substring(1, str.length());*
>> *}*
>>
>> Joining path part:
>> *def PathJoin(path1, path2) {*
>> *String p1 = ToUnixPath(path1);*
>> *String p2 = ToUnixPath(path2);*
>> *if(p1.length() > 1 && p1.endsWith("/")) {*
>> *p1 = RemoveLastChar(p1);*
>> * }*
>> *if(p2.startsWith("/")) {*
>> *p2 = RemoveFirstChar(p2);*
>> * }*
>> *if(p1 == "/") {*
>> *return p1 + p2;*
>> * }*
>> *if(p1.length() == 0) {*
>> *return p2;*
>> * }*
>> *if(p2.length() == 0) {*
>> *return p1;*
>> * }*
>> *return p1 + "/" + p2;*
>> *}*
>>
>> *def PathsJoin(paths) {*
>> *String result_path = "";*
>> *if(paths instanceof List && paths.size() > 0) {*
>> *result_path = paths[0];*
>> *for(int i = 1; i < paths.size(); ++i) {*
>> *result_path = PathJoin(result_path, paths[i]);*
>> * }*
>> * }*
>> *return result_path;*
>> *}*
>>
>> And to get the workspace root, you can use the pwd command, when the 
>> script start onto the node, the current dir is the workspace, so you could 
>> save it into a var with pwd command at the beginning. After use the path 
>> join above to recreate some path.
>>
>> https://www.jenkins.io/doc/pipeline/steps/workflow-basic-steps/#pwd-determine-current-directory
>>
>>
>> On Monday, September 13, 2021 at 2:30:18 AM UTC-4 ice...@googlemail.com 
>> wrote:
>>
>>> Hi,
>>>
>>> no, not really. Especially as  workspaces typically are reused between 
>>> jobs such an URL would be at leas open to surprise.  Best practice is to 
>>> archive such files (log output, generated files. ) as  artifacts to get 
>>> persistence. 
>>>
>>> Björn
>>>
>>> davidmic...@gmail.com schrieb am Freitag, 10. September 2021 um 
>>> 22:09:36 UTC+2:
>>>
>>>> I do notice that my build has a "BUILD_URL" var in the environment, so 
>>>> that gives me the "prefix" of the url, but the url to the file in the 
>>>> workspace has pieces like the following after the BUILD_URL value: 
>>>> "/execution/node/22/ws/". I don't see anything else in the environment 
>>>> that 
>>>> can help me construct that part of the url.
>>>>
>>>> On Friday, September 10, 2021 at 9:22:16 AM UTC-7 David Karr wrote:
>>>>
>>>>> When a Jenkins build completes, I can navigate to "Workspaces" to 
>>>>> manually inspect files in the workspace.  While I'm navigating that tree, 
>>>>> and viewing specific files, I can see that the current browser url goes 
>>>>> directly to that point in the tree, and to the specific file I am viewing.
>>>>>
>>>>> Is there a practical way in a Jenkins scripted pipeline, to CONSTRUCT 
>>>>> a url to a file in the workspace so I can print it out in the log, to 
>>>>> enable a single click to get to a particular file?
>>>>>
>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/3a2c4e8b-d042-43cd-9a83-fd7c87dc6594n%40googlegroups.com.

Reply via email to