Re: Any way to construct a url to a particular file in the jenkins workspace?

2021-09-27 Thread 'Björn Pedersen' via Jenkins Users



>
> That "our local path" thing is not clear to me. What exactly would that 
> be?  If the file I create is in the root directory of the workspace , would 
> that "local path" be empty?
>

Correct. The pathes you specify are relative to the workspace part. To 
check just compare the 

-- 
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/59fa524c-fdb9-4727-b497-f0e498c1bf80n%40googlegroups.com.


Re: Any way to construct a url to a particular file in the jenkins workspace?

2021-09-22 Thread David Karr
On Wed, Sep 22, 2021 at 8:16 AM 'Björn Pedersen' via Jenkins Users <
jenkinsci-users@googlegroups.com> wrote:

>
>
>> I'm not familiar with the archive process. If you could provide me some
>> quick links for information, that would be useful. I'll also ask our
>> internal ops team.
>>
>>
>
> Archiving is not something  special, it's a standard feature.
> in a scripted pipeline:
>
> archiveArtifacts artifacts: '**/*.log'
> (just use the script builder for more help)
>
> link to:
> $BUILD_URL/artifact//
>

That "our local path" thing is not clear to me. What exactly would that
be?  If the file I create is in the root directory of the workspace , would
that "local path" be empty?

-- 
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/CAA5t8Vr6RQHNW2NCKBdkAjqgNt3Ra1pN01LU6KsXbk50CVcwkA%40mail.gmail.com.


Re: Any way to construct a url to a particular file in the jenkins workspace?

2021-09-22 Thread 'Björn Pedersen' via Jenkins Users


>
> I'm not familiar with the archive process. If you could provide me some 
> quick links for information, that would be useful. I'll also ask our 
> internal ops team.
>
>

Archiving is not something  special, it's a standard feature.
in a scripted pipeline: 

archiveArtifacts artifacts: '**/*.log' 
(just use the script builder for more help)

link to:
$BUILD_URL/artifact//

Björn

-- 
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/0afebe05-f291-4271-ac72-7f98f26637f3n%40googlegroups.com.


Re: Any way to construct a url to a particular file in the jenkins workspace?

2021-09-22 Thread David Karr
On Wed, Sep 22, 2021 at 7:29 AM 'Björn Pedersen' via Jenkins Users <
jenkinsci-users@googlegroups.com> wrote:

>
>
> db...@cloudbees.com schrieb am Mittwoch, 22. September 2021 um 14:54:48
> UTC+2:
>
>> On Mon, Sep 13, 2021 at 5:49 PM Jerome Godbout 
>> wrote:
>>
>>> Humm, that would be hard and security unwise. The executing node path
>>> aren't available to the web.
>>
>>
>> They are in the case of workspace files (to users with appropriate
>> permissions).
>>
>> I think the problem is that it's difficult to obtain the pipeline node ID
>> for the `node` step allocating the workspace.
>>
>> Between the BUILD_URL and WORKSPACE (the prefix of the path to remove),
>> the rest should be known.
>>
>
> I the another problem that is more important (at least in general): The
> workspace is not persisted as part of the job, instead it
>  may well get reused  and/or cleaned once the job is finished. So clicking
> the link on an older job may well get you the file from
> a newer run. That's why I really recommend to just archive this file as
> artifact and use the artifact link( which is stable and easier to construct)
> instead.
> Björn
>

I'm not familiar with the archive process. If you could provide me some
quick links for information, that would be useful. I'll also ask our
internal ops team.

-- 
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/CAA5t8VqFQ2LP2B9KZ%3D%3DShbWXLuG347Vi%2B5FBPRN5ROOY13G_qg%40mail.gmail.com.


Re: Any way to construct a url to a particular file in the jenkins workspace?

2021-09-22 Thread 'Björn Pedersen' via Jenkins Users


db...@cloudbees.com schrieb am Mittwoch, 22. September 2021 um 14:54:48 
UTC+2:

> On Mon, Sep 13, 2021 at 5:49 PM Jerome Godbout  
> wrote:
>
>> Humm, that would be hard and security unwise. The executing node path 
>> aren't available to the web.
>
>
> They are in the case of workspace files (to users with appropriate 
> permissions).
>
> I think the problem is that it's difficult to obtain the pipeline node ID 
> for the `node` step allocating the workspace.
>
> Between the BUILD_URL and WORKSPACE (the prefix of the path to remove), 
> the rest should be known.
>

I the another problem that is more important (at least in general): The 
workspace is not persisted as part of the job, instead it
 may well get reused  and/or cleaned once the job is finished. So clicking 
the link on an older job may well get you the file from 
a newer run. That's why I really recommend to just archive this file as 
artifact and use the artifact link( which is stable and easier to construct)
instead.
Björn
 

-- 
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/d26036f1-fdeb-4b48-a080-d60098bd0f4an%40googlegroups.com.


Re: Any way to construct a url to a particular file in the jenkins workspace?

2021-09-22 Thread Daniel Beck
On Mon, Sep 13, 2021 at 5:49 PM Jerome Godbout <
jerome.godbout.amo...@gmail.com> wrote:

> Humm, that would be hard and security unwise. The executing node path
> aren't available to the web.


They are in the case of workspace files (to users with appropriate
permissions).

I think the problem is that it's difficult to obtain the pipeline node ID
for the `node` step allocating the workspace.

Between the BUILD_URL and WORKSPACE (the prefix of the path to remove), the
rest should be known.

-- 
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/CAMo7PtJA9oFnKzO08NewVqzQcMfytW9p7AzXJvuXAJjG3QrjxA%40mail.gmail.com.


Re: Any way to construct a url to a particular file in the jenkins workspace?

2021-09-13 Thread Jerome Godbout
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 

Re: Any way to construct a url to a particular file in the jenkins workspace?

2021-09-13 Thread David Karr
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/dbd45854-9e8f-402e-9243-29a1181b6257n%40googlegroups.com.


Re: Any way to construct a url to a particular file in the jenkins workspace?

2021-09-13 Thread Jerome Godbout
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/14c806a7-7337-48a1-9cb7-c2a112a99372n%40googlegroups.com.


Re: Any way to construct a url to a particular file in the jenkins workspace?

2021-09-13 Thread 'Björn Pedersen' via Jenkins Users
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/3124e21e-9b34-4359-9e83-d0401ac64ec0n%40googlegroups.com.


Re: Any way to construct a url to a particular file in the jenkins workspace?

2021-09-10 Thread David Karr
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/d3dbf8b8-93c0-4194-8311-bac7656b90b6n%40googlegroups.com.


Any way to construct a url to a particular file in the jenkins workspace?

2021-09-10 Thread David Karr
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/CAA5t8VrTcOF-1AtCS_%3DfnR9hhfQmF%2BSJ8J62pyVtWqJs-neFag%40mail.gmail.com.