How to get all Jenkins job ran between specific dates?

75 views
Skip to first unread message

Alok Dubey

unread,
May 12, 2023, 5:36:50 PM5/12/23
to Jenkins Users
Hi There,

I am looking for a way to gather Jenkins's usage statistics such as builds run every month or day. I came across a script at https://github.com/jenkinsci/jenkins-scripts/blob/master/scriptler/jobExecutedInDateRange.groovy. However, it is not working as expected.

https://plugins.jenkins.io/global-build-stats/ is also not working as expected and we don't want to use this plugin for security reasons.

How can I achieve this? Please advise.

Thanks in advance!

Fabian Cenedese

unread,
May 13, 2023, 3:08:10 AM5/13/23
to jenkins...@googlegroups.com
I was looking for similar information, so I could see when many jobs want
to use the same lockable resource or when an agent could be better used.
As I couldn't find such information I resorted to the API (via web calls) to
poll for running jobs and locked resources. This information is stored in
a file where I can then use a script to create a table of when was running
what and where. You could probably do the same to get the desired
statistics out of this data. I wrote it in python as there's a plugin to access
Jenkins but maybe someone with more internal knowledge could turn this
into a Jenkins plugin.

import jenkins

server = jenkins.Jenkins('http://YOURJENKINS', username='USER', password='PASS', timeout=300)
queue = server.get_queue_info()
running = server.get_running_builds()

Maybe that helps. If there is a better way I'd be glad to hear about it as
I don't like my solution too much either.

bye Fabi

Reply all
Reply to author
Forward
0 new messages