Jenkins: How to make single job build and deploy on two servers

前端 未结 6 784
刺人心
刺人心 2021-02-06 15:37

I have code in a repository. Now I want to create a job which will build code from the repository and deploy it on two servers.

Right now I create two jobs with exactly

6条回答
  •  伪装坚强ぢ
    2021-02-06 15:51

    You can deploy to multiple servers using the Node and Label parameter plugin.

    Add the servers you want to deploy your code using Jenkins nodes: Manage Jenkins > Manage nodes > New node.

    Be sure to add a label to each node so you can group them together and deploy to that group.

    Create a new freestyle project and check the This project is parameterized option. Add a parameter and choose Label, and add the label you just created for your servers (nodes).

    From here, every build step will replicate itself in each labeled node, so you can fetch your repository code using a SCM plugin, GitHub, GitLab, etc. or directly from your server, this is up to you, and the code will be deployed on each node.

    Be aware that if your code need to be compiled, it will be compiled on the remote server. Also, every time this build is deployed to a node, will create an additional build in your build queue.

提交回复
热议问题