3

I am struggling on a situation where I have to display a graph(an image) of jenkins within another application. When I stay logged into jenkins(different tab in the same browser), the other application is able to use that image url to display the graph. But when I logged out from jenkins, the graph is not allowed to be accessed since the browser no more is having an authenticated jenkins session.

If I know the username and password to log into jenkins, how can I make this image displayed(authenticating and calling the image url within the other application), without manually logging into jenkins?

Thank you.

Chathura Kulasinghe
  • 2,640
  • 5
  • 23
  • 23

1 Answers1

2

Jenkins supports regular HTTP authentication. Though you should use the API token of your Jenkins account, rather than the password.

You can find your API token on your user page: cclick your username in the top-right corner of Jenkins, then the Configure link.

With these details, you can refer to an artifact within Jenkins, e.g.:

http://USER:API-TOKEN@JENKINS/job/JOB-NAME/lastSuccessfulBuild/artifact/graph.png

Christopher Orr
  • 110,418
  • 27
  • 198
  • 193
  • Hi Christoper, Thank you very much for your kind attention and the quick reply! I just tried what you suggested. I have installed jenkins on my local machine. If I used the following url for the image 'src' `http://me@mycompany.com:cgdhsgs53625262vsgs@localhost:8080/job/JOB-NAME/lastSuccessfulBuild/artifact/graph.png` Should this work? I did try this but it didn't work. By the way I truly appreciate your answer for my question!!! I assume that this approach would work.Please do mention whether I've done something wrong here. Thanks. – Chathura Kulasinghe Dec 06 '12 at 04:56
  • It gave me the similar result; which is that I can load the image while being logged in to jenkins admin console(another tab of the same browser) and the image is not displayed anymore after I signed out of the jenkins admin console. – Chathura Kulasinghe Dec 06 '12 at 05:21
  • 1
    If your Jenkins user ID has an `@` symbol in it, you probably need to URL-escape it as `%40`. – Christopher Orr Dec 06 '12 at 13:53
  • Yes Christoper. I did that as well. But still the image doesn't appear. In firebug console (NET) I can see that it gives the error like this `NetworkError: 403 Forbidden - http://me%40mycompany%2Ecom:139fffj393j38e042264a3b055774522@localhost:8080/job/JOB-NAME/lastSuc‌​cessfulBuild/artifact/graph.png` – Chathura Kulasinghe Dec 07 '12 at 04:15
  • I am facing a similar issue , did anyone find a solution/workaround ? – user3540835 May 12 '16 at 09:29