Creating a Job by using Build Periodically
Launch EC2 instance with Amazon Linux2 Kernel 5.10(AMI) along with port numbers set SSH – 22, HTTP 80 and custom tcp is 8080 and select storage t3.micro. Here we are providing port 8080 for jenkins because jenkins run on port 8080
Now connect with git bash terminal by using SSH Client
Now browse official website of jenkins and copy the commands install jenkins packages by using following commands
sudo wget -O /etc/yum.repos.d/jenkins.repo \https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
After completion of jenkins packages now we need to install Java because jenkins runtime is java. Install by using following commands,
sudo yum -y install java-17*
Now install jenkins by using following command, here sudo means superuser permission without this permission we cannot install jenkins
sudo yum -y install jenkins
After completion of jenkins installation, now start and enable the jenkins and also check status of the jenkins it was running or not by using following commands
sudo systemctl start Jenkins
sudo systemctl enable Jenkins
sudo systemctl status Jenkins
Now copy Public IP of your instance and Browse it along with Port 8080, because jenkins runs on port 8080
example;
123.34.54.78:8080, like this we have to browse in browser.
Now Jenkins page was open but is ask administration password, this administration password was enable when we check the status of the jenkins. It shown in below figure, copy and paste your administration password and fill all necessary details. Remember username and password.
This is the official page of jenkins
Now click on New Item
Here give project name and select freestyle project and click on and move to next step
In the job configuration page, let’s scroll down straight to the Build Triggers section. Since we intend to create a straightforward job, let’s select the checkbox marked Build periodically. As soon as we select this checkbox, a Text Box is displayed with the Schedule label.
We have to provide value in a Cron-compliant format.
After that go to build triggers in build triggers there is an option build periodically in that give as you like time, here i am giving * * * * * to run the job every minute
* * * * *
* (Minutes): The job runs every minute.
* (Hours): The job runs every hour.
* (Days of the Month): The job runs every day of the month.
* (Months): The job runs every month.
* (Days of the Week): The job runs every day of the week.
So, the expression * * * * * effectively means “run the job every minute.”
Since we’ve configured the job to run every minutes, we should see multiple build numbers when we go back to the job dashboard after waiting for some time.
In build steps there is an option execute shell in that give following commands
Now create another job for build purpose, here we are creating two jobs one is for clone job and build job and also setup for CI/CD pipeline view
In build triggers select build after other projects this option for pipeline and in build steps follow below commands
Now clone job and build job was completed, we setup a * * * * * run the job every minute, so it build automatically per every minute.
Same output we can see in pipeline view it shown in below figure
How Do I Schedule Jobs In Jenkins?
Jenkins, an open-source automation server, engages teams to automate different tasks, from building and testing to deploying software. One crucial part of Jenkins is its capacity to plan occupations, empowering the execution of mechanized processes at specified intervals of time. This guide gives insights into the significance of scheduling jobs inside Jenkins, permitting users to smooth out dull errands, improve efficiency, and layout ceaseless incorporation and delivery practices.
Scheduling jobs in Jenkins includes defining when explicit automation undertakings should run, whether it’s every day builds, daily deployments, or other customized schedules. Through the configuration of build triggers and the utilization of cron articulations, users can fit work timetables to accommodate their advancement needs. This guide expects to demystify the interaction, enabling clients to harness the maximum capacity of Jenkins for proficient and automated software development.