Pergunta

I have a jenkins server running, and for a job I need to download a file which is in the jobs/builds/buildname folder.

How to download that file from jenkins job?

Foi útil?

Solução

If you would use the workspace as suggested by previous post, you can access it within a Pipeline:

sh "wget http://<servername:port>/job/<jobname>/ws/index.txt"

Or inside a script:

wget http://<servername:port>/job/<jobname>/ws/index.txt

Where index.txt is the file you want to download.

Outras dicas

I rock a Unix based development machine and a Unix based Jenkins machine up in the cloud. This means I can use the SCP Command to download the remote file over an ssh connection. This is the anatomy of my scp commands:

scp -i <path/to/ssh.pem/file> <user>@<jenkins.remote.url>:<path/to/remote/file> <local/path/where/download/goes>

This works for directories too, for instance I use this to download backups generated by the ThinBackup Plugin

You had already been given the answer for getting the file from the workspace

http://<servername:port>/job/<jobname>/ws/filename.ext
Obviously replace stuff in <..> with values relevant to your setup, and make sure anonymous user has access to read from workspace, else you may have to login.

The only other files you could access are those that are archived from previous job runs.
http://<servername:port>/job/<jobname>/<buildnumber>/artifact/filename.ext
Where <buildnumber> is the build number you see in job build history, or one of the permalinks provided by Eldad (such as lastStableBuild). But this will only have access to archived artifacts.

You cannot arbitrarily access files from Jenkin's filesystem through the web interface... it wouldn't be very secure if it did let you.

The Jenkins job's build folder is meant for logging and plugins reports. You should not need to access it directly.

If you must, you can access it relative to the workspace: $WORKSPACE/../builds/$BUILD_ID/

You can also replace the $BUILD_ID with one of the links Jenkins creates:
lastFailedBuild
lastStableBuild
lastSuccessfulBuild
lastUnstableBuild
lastUnsuccessfulBuild

I hope this helps.

As others have pointed out this path should work, I like to highlight that the "ws" is a directory in Jenkins:

http://<servername:port>/job/<your job>/ws/<your file>

Download the Package lynx (Command line browser)

    $ apt-get install lynx

or

    $ yum install lynx

then use the command

   # lynx http://<servername:port>/job/<jobname>/ws/file

The App Will Ask you to allow cookies and if there are authentication will direct you to login page like the browser.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top