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 [email protected] 
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 [email protected] 
> 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
>>
>> [email protected] 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/dbd45854-9e8f-402e-9243-29a1181b6257n%40googlegroups.com.

Reply via email to