Skip to main content

Find Jenkins projects that build periodically

Comments

1 comment

  • Shinta Smith

    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.

About CloudBees Support

Our Support Engineers are available to help with any questions or problems you may have with any of our products.