?? Day 2 ??: Create the first Jenkins job and create a directory on a machine using Jenkins.
Vaibhav Jain
DevOps | Cloud | AWS | CI/CD | Red Hat Linux | Git/Github | Docker | Ansible | Terraform | Kubernetes | Networking
what is the meaning of Jobs in Jenkins?
a job is a set of tasks defined and run by users to perform work. Jobs are a key part of the build process and can be used to test applications or projects. They can encapsulate a specific task or process within the CI/CD pipeline, such as compiling source code, running tests, or deploying applications. Jobs are executed automatically and run sequentially as defined by the user.
so now we are connecting my Jenkins to the GitHub repository:
so the first step is creating the job:
This is the freestyle project so we click on freestyle and then click on ok:
Here we can put any description for our Job:
This is because we have to create the GitHub repository copy the link of the repo and connect to the Jenkins:
Now the step is connecting the GitHub to the Jenkins so we have to put the Github repo link in the source code management folder:
so if we get this type of error that means we had not installed the git package in our Amazon EC2 machine:
command to check the git in our machine:
sudo git status
so firstly we have to install the git package on our machine:
The command for the install the git in our machine:
sudo yum install git
now we can see that the error has gone:
Here we have to correct the Branch name in case of its difference:
in my case, its name is Main so we changed it:
Here is we have apply and save:
so we have to come on the dashboard and we can see that our job is ready:
so now we can see a build button. So now we have to click on it and our build is started on the left we can see that:
After the completion, we can see the time of the last success N/A to any minutes that we see. on the page that is updated and now.
领英推荐
the symbol on the right is green so we can see that our build is run successfully.
so now we can see the console output of the build that is finished successfully.
now we can run any command in the configuration > Build step > Execute shell
and put any command that we want:
so we want to create the jenkins file at this location:
so now we do apply and save to run this command and want to create the jenkins file at this location:
so we run this build:
now we got the error for like some permission denied.
so we change the command and put it with the sudo command and apply and save.
after all, we start build:
we got the same output from the build.
so the error is for when we work on the web UI of Jenkins it works with like Jenkins user, not that user that we put the name in the Jenkins web that we put the name like limitlesseminence.
but our limitlesseminence user runs any command on the backend as a Jenkins user. only for the web login we have to put the credentials of the limitlesseminence user that we put in while the first time login.
so we have to check the user on the machine. so for checking the user on the machine, the command is:
cat /etc/passwd | grep jenkins
as we can see that u id of the Jenkins user is 995. which means that we can not log in with this user. This is the system user.
so the point is if the jenkins user is the list on the sudo user? if it is not on the sudo user list how it can work for the sudo users.
Here is the file location. In this file, you can edit the sudo user permissions:
cd /etc/sudoers.d/
so in the file you can edit the user and its permissions:
so here is the open file:
so we edit the in file for jenkins user:
so after saving the file we build the job:
so now we successfully completed the build. and we can see that the directory is created.
Congratulations! Your directory is created by the build. now we can see these on our machine.
so this is our Day 2 with the Jenkins mastery challenge. Today we created the directory on the machine with the help of the Jenkins job. Tomorrow we deploy our first website with the Jenkins job. Make yourself ready for Day 3 with #DevopsWithVaibhav.