1

The following page in Jenkins is supposed to list the builds started by a user user -

https://<jenkins.domain>/user/<username>/builds

But this is always empty for all users in my Jenkins.

There are no errors in System Log or in the browser. Not sure why this page is always empty.

Environment:

Jenkins version: 2.190.2 

Auth mechanism: LDAP

I'm looking for an API to get all builds executed by a given user(or currently logged in user). Ideally if this page was working, I would have checked the Rest API being used by the page from the Rest API link in Jenkins footer.


The question is same this 5 year old question on an older version of jenkins which doesn't have any answer - Jenking not displaying build history from a single user

Edit: Still looking for a way to list pipeline jobs started by a user.

Shashank V
  • 10,007
  • 2
  • 25
  • 41
  • Somethings I would try... (1) Check if I am logged in as an `admin` user (2) trigger a job as `admin` user and simultaneously check if the `running` job is displayed in the link you have mentioned. – mdabdullah Aug 08 '20 at 09:08
  • Does this only work for "admin" user? I'm trying to figure out the admin password as i don't seem to have it anymore after the initial setup. I'm trying with a user account which has all the admin permissions though. – Shashank V Aug 10 '20 at 14:06
  • You are right your account is sufficient. Did you try (2) – mdabdullah Aug 10 '20 at 16:54
  • Yes. Already tried that. – Shashank V Aug 10 '20 at 18:50
  • I think I understand your problem, the page you have specified displays jobs based on the groups of the user. I just tested on mine and found that when I do `https:///user/mdabdullah/builds` I get only 1 job listed, but when I do `https:///user/mdabdullah@company.com/builds` I get around 250 jobs listed, I would suggest you play around with your user accounts in your org to find the correct link in which you can list all the jobs. Another note, it does seems like it is listing `freestyle` jobs more accurately than `pipeline` jobs. – mdabdullah Aug 11 '20 at 05:49
  • 1
    I tried all combinations of user/group but nothing worked. But your observation about freestyle jobs is correct. All the jobs in my jenkins are pipeline jobs. So I created a freestyle job to test and after running these, these jobs are visible in the builds page. Do you know if there is way to get pipeline job history for a user? Can you add your comment as an answer so that I can accept it. – Shashank V Aug 11 '20 at 07:54
  • I looked into fetching `pipeline jobs` by `username` and find that it is not available. I think it is because this feature is OOTB of the `BUILD` plugin which is available in `Freestyle` and `Maven` type jobs and not available in `Pipeline` type jobs. You can look for other plugins or options, if you decide to bootstrap this is what you need to do: Develop a `groovy` or `shell+groovy` script to run on the `master`. This script will scrape the `console output` of each job build history and you can `grep` the first line and `truncate` the rest of the log, the first line contains the username. – mdabdullah Aug 11 '20 at 17:46

1 Answers1

2

Jenkins users can authenticate on different Security Realms i.e., group based access (SAML) or LDAP based authentication so the queries have different ways of getting fetched.

When I compare the number of jobs of the following URLS, the results are actually different:

https://<jenkins.domain>/user/<username>/builds -- Returns only one https://<jenkins.domain>/user/<username>@company.com/builds --Returns many

Identify the format in your Jenkins instance to find the correct link in which you can list all the jobs.

Another point to note, this page lists only Freestyle jobs and not Pipeline jobs.

mdabdullah
  • 596
  • 1
  • 9
  • 25