2.0 KiB
2.0 KiB
Exercise 10
You will start a VM using Vagrant as practice environment to set up a distributed build with 2 agents.
Starting up the VMs
- To start up the VMs, navigate to this directory. It should contain a
Vagrantfile. - Run the command
vagrant up. Bringing up the VMs might take some minutes. The two VMs will be available with the IP address192.168.99.201and192.168.99.202. The username/password credentials for those VMs arejenkins:jenkins.
Configuring and Executing Jobs in a Distributed Build
- Go to "Manage Jenkins" > "Manage Nodes". You should see a single
masternode. - Configure the
masternode by setting the # of executor value to 0. That will take care of never using themasterfor job workload. - Add new nodes by clicking "New Nodes". Enter an appropriate name and select the option "Permanent Agent". Use the remote directory
/home/jenkins/jenkins_slaveand set the # of executors to 2. Enter the IP address192.168.99.201as host and provide credentials by selecting "Username with password". You will likely have to create a new credential. To keep things easy select "Non verifying Verification Strategy". - Trigger a build. You should see that the build is only executed on the agent and not the
masternode. - Add one more agent with the IP address
192.168.99.202. - Trigger a build. You should see that the build can be executed on any of the agents.
- Configure one of the agents to only build jobs with a specific label e.g.
java. Change the "Usage" field to "Only build jobs with label expressions matching this node". - Configure the
gradle-initializrjob and assign the labeljava. - Trigger a build of the
gradle-initializrjob. It is only executed by the dedicated agent. - Trigger other jobs that do not have the label
javaassigned to them. They are waiting for an agent that can execute the build.
Shutting down the VMs
- After you are done with the exercise, navigate to the directory containing the
Vagrantfile. - Tear down the VM by executing
vagrant destroy -f.