HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Launch jenkins agent from jenkins job?

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
jenkinsagentlaunchfromjob

Problem

Is it possible to launch a jenkins agent from within a script in another job? I'm open to either shell or pipeline options.

To be clear I don't mean the agent the job is running on itself. I'm talking about spinning up a completely separate agent.

Sometimes our master gets slammed with unit test requests and will make jobs wait in the queue for 15-20+ minutes instead of just spinning up more agents. I want to see if there's a way to spin an agent up intentionally so I can tie it into a job that polls the queue for wait times.

Solution

What you are looking for is called dynamic provisioning of Jenkins' slaves, and yes this is doable. Setting it up depends upon your desired infrastructure provider/resource. The easiest example in my opinion is using AWS EC2 instances. Install the Amazon EC2 Plugin for Jenkins, and configure it with the appropriate access keys, IAM roles, etc. to allow it to provision EC2 instances in a specified VPC. Here is a short (but slightly outdated) guide.

If you are moving to K8's and Docker, you may want to consider looking into the Docker Plugin for Jenkins. If you are using bare bones infrastructure, this should allow you to more effectively utilize what current hardware you have.

Context

StackExchange DevOps Q#3544, answer score: 1

Revisions (0)

No revisions yet.