Skip to content

Be able to set the seed-job-agent to "Only build jobs with label expression matching this node" #1014

Open
@renovate-eika

Description

@renovate-eika

Describe the solution you'd like

  • Be able to set the seed-job-agent to "Only build jobs with label expression matching this node"
  • Be able to scale the number of executors on the seed-job-agent

The reason behind this is that we have many multibranch pipelines which are pointing to Jenkinsfiles without any requirements of using node labels. We only use labels if they need to use a special node that is not on the "golden path". On the Jenkins server we decide which agents should be used as much as possible.

Describe alternatives you've considered

Since the seed-job is by default labeled/restricted to use "seed-job-agent", I think the agent could be set to only build the jobs with matching labels, or at least an option to set these settings.

I have tested to do this with the following groovy script added to "groovyScripts" without any success:

apiVersion: v1
kind: ConfigMap
metadata:
  name: seed-job-agent
data:
  seed-job-agent.groovy: |2
    import jenkins.model.Jenkins
    import hudson.model.Node.Mode

    def agentName = 'seed-job-agent'
    def newExecutors = 1  
      
    def agent = Jenkins.instance.getNode(agentName)
    if (agent != null) {
      agent.setNumExecutors(newExecutors)
      agent.setMode(Mode.EXCLUSIVE)
      agent.save()
      println("The number of executors for agent '${agentName}' has been set to ${newExecutors} and configuration saved.")
      Jenkins.instance.reload()
    } 

Additional context

There may be use-cases I haven't thought through

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions