PlugIn that auto-delete a job after a period of inactivity time

13 views
Skip to first unread message

Davide Mendolia

unread,
Aug 4, 2012, 4:46:17 AM8/4/12
to jenkin...@googlegroups.com
Hi,

I'm searching for a plugIn that auto-delete a job if build didn't run for X days.
I can't find one, do you know if there is something similar, or I will start to write a plugin for that.

Thanks
--
Davide Mendolia

Tan Yeong Sheng

unread,
Aug 5, 2012, 9:09:51 PM8/5/12
to jenkin...@googlegroups.com

i don’t think so. but i would like to help you with building the plugin

Vojtech Juranek

unread,
Aug 6, 2012, 6:36:41 AM8/6/12
to jenkin...@googlegroups.com
Hi,
I'm not aware of such plugins, we usually use Jenkins jobs for such tasks like
cleanup old jobs/builds etc.

Periodic job with e.g. following system groovy script as a build step could do
the job:

long LIMIT = 2L*365*24*3600*1000 // 2 years in millis
long NOW = System.currentTimeMillis()
jenkins.model.Jenkins.instance.items.each{job ->
if(job.lastBuild != null && (NOW - job.lastBuild.timeInMillis) > LIMIT) {
println "Deleting ${job.displayName}
job.delete()
}
}

HTH
Vojta
Reply all
Reply to author
Forward
0 new messages