简体   繁体   中英

How to run jenkins build alternatively on slave nodes?

Let's say I have a job A and also a slave configured. I want to run build 1 of Job A on master and build 2 of Job A on slave node. Is there an option to achieve that ?

OR

Is there a way where my job looks at master and if it already finds a build running, then start the next build on slave ?

Are you intending to run in parallel or just alternate? (Not a good idea to run jobs on master; could configure a node to run on same host as "master".). Seems to be parallel and you have restricted to one executor each on master and agent (you can have more, in which case any advice may be moot).

Nevertheless, Jenkins queue job allocation to executors is "sticky"; it tries to run where last run, unless unavailable. This can lead to overloading in nodes. So the M,A,M,A pattern is unnatural.

There are plugins that might help: Least Load , Scoring Load Balancer , but maybe not.

Perhaps an approach would be to restrict your job using a label and have a post-build groovy step that moves the label to the other upon success for the next run or two labels and the job self-modifies the label to match the other.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM