Limit Jenkins node slaves based on time of day

I have a farm that is busy during the day for developers, but not open at night.

I have a second farm that is busy at night, but rarely during the day.

Is there a way to assign a node job not only by label but also by time of day?

So, if I have build_node and reression_node labels. I could run a job to run on nodes where node label is ((build_node if between 9pm-5am) or regression_node)

?

Thank.

+3


source to share


1 answer


As a workaround, you can create a jenkins job that will assign jobs to the desired nodes and schedule that job to run according to your needs.

For example, a job with the following groovy script denoted as Execute system Groovy script

assigns all jobs to the template regression node

in its job description to a shortcutregression-node



import hudson.model.*

jobs=Hudson.instance.getItems()
for (job in jobs){

    description = job.getDescription()
    if (description =~ /regression-node/){
        println ("Assigning $job to the restriction-node")
        label= Hudson.instance.getLabel('regression-node')
        job.setAssignedLabel(label)
    }

}

      

+1


source







All Articles