I am trying to create a connector which invokes the available Jenkins REST endpoints to flow the necessary Job and Pipeline details to another tool, lets say JIRA, and I am trying to get a list of filtered Jobs from Jenkins based on a datetime criteria, e.g jobs created after 12pm of a given date.
Currently all I can get is the following API which returns all Jobs which are there:
{Jenkins_ServerUrl}/api/json
Is there any endpoint available where I can apply the datetime filter?
I don’t believe there is an api endpoint for exposing time based operations in Jenkins. The closest similar action in the UI is the Build History.
The only alternative solution will be to run a shell command on Jenkins “Built In”: agent.
Something like below on the folder that you’d like to get the jobs from in $JENKINS_HOME/jobs/
It’s unlikely you are going to find a reliable answer.
AFAIK, Jenkins job (config.xml) has no inherent “date created” property. Every time the job is updated, so is the timestamp on the file, so that negates @idan’s solution (unless you never alter a job, incl. disable/enable).
At best you would learn when the job was last modified, incl. disable/enable. Also, the Build History is only valid as long as you never discard build history (which is now enabled as a global option as of 2.221.1)
You could install Job Configuration History for forward looking information, though I don’t know what it exposes via REST API / json.