How to run jenkins build alternatively on slave nodes?

£可爱£侵袭症+ 提交于 2021-01-28 12:20:55

问题


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 ?


回答1:


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.



来源:https://stackoverflow.com/questions/64130656/how-to-run-jenkins-build-alternatively-on-slave-nodes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!