Search code examples
jenkinsjenkins-pipeline

Use different nodes when same job is run simultaneously


I try to achieve the following: I want to run the same Jenkins pipeline job twice, but not on the same node. In the job I have defined some labels for choosing the correct agent. The nodes to be used are EC2 cloud nodes. They are configured with just one executor and an instance cap of 2. So in theory, I would expect that when starting two builds, it spawns two EC2 machines and runs one build on each machine.

But what actually happens is, the first job triggers creation of a new ec2 machine. The second job then sits and waits for the first job to complete and then uses the same machine.

Is there a configuration option to achieve the wanted behavior? I tried the "Throttle concurrent builds" plugin mentioned in this SO question, but it didn't do what I wanted. What am I missing?

Thanks for any hint.


Solution

  • This is a limitation of the Jenkins EC2 plugin I think.

    A known issue can be found at https://issues.jenkins.io/browse/JENKINS-26716.

    A workaround is, set the Spare Instances parameter to 1. This will keep an instance always on, but scale up one by one each time.