Find Jenkins projects that build periodically Bee Bot July 13, 2022 10:59 Updated The content of this article has moved to the new documentation site. Related articles Groovy to list all jobs Pipeline - Build failed due to MissingPropertyException: No such property: env How to install Windows agents as a service? GitHub webhook triggering is delayed How to Connect to Remote SSH Agents? Comments 1 comment Sort by Date Votes Shinta Smith February 26, 2020 19:32 I updated the groovy script to distinguish more causes: Jenkins.instance.getAllItems(Job).each{ def jobBuilds=it.getBuilds() // Check the last build only jobBuilds[0].each { build -> def runningSince = groovy.time.TimeCategory.minus( new Date(), build.getTime() ) def currentStatus = build.buildStatusSummary.message def cause = build.getCauses()[0] //we keep the cause def causeClass = cause.getClass().getSimpleName() switch (causeClass) { case "BranchEventCause": println "[SCM Push Event] ${build}" break; case "BranchIndexingCause": println "[Branch Indexing] ${build}" break; case "UserIdCause": def user = cause.getUserId() println "[${user}] ${build}" break; case "TimerTriggerCause": println "[Timer] ${build}" break; } }}return 0 Please sign in to leave a comment.
Comments
1 comment
I updated the groovy script to distinguish more causes:
Please sign in to leave a comment.