Sreevalsa E
Sreevalsa E

Reputation: 986

How to check if Jenkins node1 is free for the job, if not check for the node 2 and trigger the build on node2?

I have a job which has the node name as a parameter(Made possible using NodeLabel Parameter Plugin). I will trigger the job always with node1 as the parameter. I want the job to see node 1 is online and free(no other builds are going on in that node). If node1 is free run this job on node1 else this job should find a free node and run it on that(ie; trigger this same job in other node (eg; node2) if node1 is not free). How can I do that? How can I know whether a node is free? I don't want my job to be waiting for a node to complete other builds.

Upvotes: 0

Views: 743

Answers (1)

Mike
Mike

Reputation: 615

Have the same label name on both agents (for example "windows") and have your job run with label "windows". It will run in a little different manner. In this case when you run that job with target label "windows", jenkins will send the request to both nodes but jenkins will run the job on the agent which will respond first.

Upvotes: 1

Related Questions