We already installed Jenkins and currently we can access the dashboard. The next step we would try is creating job. Besides that, we will also try to connect with GitHub and manage credential for that.
1. Create Job
- Click Create a Job or New Item menu on the left hand side.
- Enter the job's name and description, then click Save.
- Click Build Now to execute the job. The action will be notified on Build History. If it turns green, means success.
- We can also go to the Console Output to see what's the job currently doing.
2. Enable SSH Key
To connect with GitHub, we need to add SSH pub-key to GitHub as credential. Because our VM is newly used, let's generate new key by running:
ubuntu@ip-172-31-17-9:~$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/ubuntu/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/ubuntu/.ssh/id_rsa Your public key has been saved in /home/ubuntu/.ssh/id_rsa.pub
Then, copy the pub-key to your GitHub account. As informed above, it's placed on
/home/ubuntu/.ssh/id_rsa.pub (please define your own path if it's different with mine).
ubuntu@ip-172-31-17-9:~$ cat .ssh/id_rsa.pub
3. Install Plugin
- Go to Manage Jenkins => Manage Plugins => Search the name.
- Checklist the column => Click Download and Install
(Please remember the steps above cause we'll do same thing when we need more plugins later).
4. Manage Credentials
After we add the pub-key to GitHub. We have to setup credential for Jenkins to make it able to connect or do anything with GitHub such as pull. Why? Because when we connect a job to SCM (in this case GitHub), it'll be doing some operations such as pull the repository. So, let's make Jenkins act as a host by copying the private key.
- Go to Manage Jenkins => Manage Credentials => Global
- Choose SSH Username with private key, then enter your GitHub's username along with the private key.
5. Add SCM To The Job
Since we've installed the Git plugin, now the option to use Git as SCM will be shown. Just copy the repository URL and choose the newly added credential. If you don't have one, you can create new repository first.
Let's check it by running Build Now!
Alright, that's it for now! Any feedback are very welcome and thank you for coming. Follow me to get notified when new post is published by me! Thank you.
Let's continue to the next part!
Top comments (0)