Setting up an AWS EC2 node as jenkins slave to a master hosted locally

Setup a password less ssh authentication for <<user>> on EC2 node

  1. Login to AWS EC2 node
  2. su to the user where you would setup jenkins slave
  3. create a key value pair
  4. add pub part of the key value pair to the authorized_keys
  5. copy the private part of the key value pair into a local file. Name it as <<user>>.pem
  6. chmod 400 <<user>>.pem
  7. test ssh to the ec2 node as <<user>> from local
    1. ssh -i <<user>>.pem <<user>>@ec2-node

Add ec2 node as slave node in jenkins

  1. scp the pem file to the jenkins master server
  2. Login to jenkins UI as admin
  3. Go to Jenkins —> Manage Jenkins –> Manage Nodes —> New Node
  4. provide /home/<<user>> as remote FS root
  5. click on advanced button
  6. provide hostname and user name
  7. leave password blank
  8. specify absolute path to the pem file for this <<user>>
  9. save and launch slave

Configure jenkins jobs to run on ec2 slave node

  1. go to jenkins job that you want to run remotely
  2. click on “Restrict where this project can be run”
  3. specify the slave name as “Label Expression”
  4. save the job and build.
Proudly powered by WordPress | Theme: Outfit Blog by Crimson Themes.