Job Scheduling per 10 secs

36 views
Skip to first unread message

Ashish Kaushik

unread,
Jun 7, 2017, 12:07:35 PM6/7/17
to jenkins...@googlegroups.com
Hi, 
I am looking for a solution which allow me schedule a job which can run every 10 secs and also the job should not run if the previous instance has not yet finished. 

I have checked the plugin store but can't find anything that supports this requirements. Any pointers would be greatly appreciated. 

Thanks
----------------------------------------------------------------------------------
 Ashish Kaushik
 SourceFuse Technologies
----------------------------------------------------------------------------------

Ramanathan Muthaiah

unread,
Jun 7, 2017, 6:53:08 PM6/7/17
to Jenkins Users
Hi ,

Freestyle or pipeline job configuration has few items that should satisfy what you're looking for.

1) Build Periodically

2) Do not allow concurrent builds.

Have you looked at them and tried to customize for your wants?

/Ram

Bill Dennis

unread,
Jun 8, 2017, 6:23:16 AM6/8/17
to Jenkins Users
I don' t think the Jenkins CRON spec has seconds resolution.

You can build an orchestrater job that is scheduled to run every 1 minute.

Then in that job, loop 6 times with a sleep of 10 seconds and build another job.

Also use the do not allow concurrent builds.

Something like this:

pipeline {


    agent any


    options
{
        disableConcurrentBuilds
()
        timestamps
()
   
}


    triggers
{
       
// Default triggering on a schedule every 1 minute or you can get from ENV
        cron
("${env.CRON_SCHEDULE?:'* * * * *'}")
   
}


    stages
{


        stage
('Trigger Job Every 10s') {
            steps
{
                script
{
                   
for(int i = 0;i < 6;i++) {


                        build job
:'foo', wait: false


                        sleep
10
                   
}
               
}
           
}
       
}
   
}
}

Have fun!

--Bill

Ashish Kaushik

unread,
Jun 14, 2017, 12:51:07 PM6/14/17
to Jenkins Users
This worked like charm. Thanks for sharing this. It saved my loads of time as I decided to write a wrapper script to handle of this. Pipeline plugin came to rescue. 
Thanks again Bill!
Reply all
Reply to author
Forward
0 new messages