0

I want to know how I can get scheduled jobs for lets say 2 days from now on. From Jenkins API.

I have nearly hundred jobs scheduled, I am having hard time tracking them. I would love a easy check on which of them are going to run tomorrow.

Typhoon
  • 178
  • 2
  • 10
  • Does this answer your question? [Schedule Jenkins job using Jenkins Rest API](https://stackoverflow.com/questions/60186314/schedule-jenkins-job-using-jenkins-rest-api) – nandilov May 02 '20 at 16:43
  • No, i am not looking for how to schedule a job. I have bunch of jobs that are already scheduled. I need to find out which of them are scheduled to run tomorrow. – Typhoon May 02 '20 at 20:28

3 Answers3

2

This groovy script should help you : DisplayCronTiggersInViewDescription.

Look for TimerTrigger (or SCMTrigger)

Personally, I would just run as a standalone groovy script or from console and forget updating the view. You also may want to look for SCMTrigger (ie Poll SCM).

This script will let you manipulate them too.

There are similar answers within s/o if you look.

Ian W
  • 4,559
  • 2
  • 18
  • 37
1

If the goal is to track future jobs, give a try with Calendar View - allows you to have a month, week and day view of past jobs (and their results) as well for the future jobs.

nandilov
  • 699
  • 8
  • 18
  • 1
    This plugin is awesome, it helps us to plan all scheduled jobs and predicts the execution time based on previous builds – jorgetutor Mar 29 '23 at 12:07
0

You could also use this to print out scheduled jobs:

import hudson.model.*
import hudson.triggers.*

Jenkins.instance.getAllItems(Job.class).each { Job job ->
  for(trigger in job.triggers.values()) {
    if(trigger instanceof TimerTrigger) {
        output = sprintf("%-30s %-30s", trigger.spec.trim().replace("\n", ", "), job.name.trim())
        println(output)
    }
  }
}