2.7 KiB
2.7 KiB
Key CI/CD/Jenkins Concepts and their Usage
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. - Have other physical or virtual machines ready that can act as agent nodes. Log into the machine as
rootuser and create a new user namedjenkinswith the commanduseradd -d /var/lib/jenkins jenkins. From themasternode, copy the contents of theid_rsa.keyfile to the clipboard. Paste the contents of the clipboard to the file/var/lib/jenkins/.ssh/authorized_keys. - 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 host and provide credentials by selecting "SSH Username with private key". 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 at least one more agent.
- 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.
Show Solution
Configure the master node.
Add a new agent node.
You will see that the master node isn't even listed anymore in the executor overview.
Reconfigure the agent node to only build jobs with a specific label.
Reconfigure the job to only use agents that can handle a specific label.
A build of the job is now only handled by an agent with the assigned label.
Other jobs sit in a queue waiting for an agent that can handle the execution criteria.






