Jenkins Job- How to create your first Build Job ?
If you are new to Jenkins and want to know, how to create your first build or Jenkins Job, this tutorial will help you to do the same.In this tutorial we will create a basic Jenkins job using its some basic features.
Recommended Article : How to Install Jenkins on Ubuntu
Also Read : How to Install Jenkins on AWS EC2
Following are step by step method to create your first build/Jenkins Job
Create your First Jenkins Job
Step 1– Log in to Jenkins.Click on Create new jobs or New Item
Step 2 – Enter the name of the project. Select Freestyle project and click on OK.
Step 3– Put the description about the Jenkins job you are creating.
Click on the check box Discard old builds and keep the value of Max # of builds to keep as 5 ( This option will allow to display your last 5 build jobs that run on Jenkins and rest will be deleted). You can increase and decrease this number as per your need.
Step 4- Keep Source Code Management as none. This option is used to create for CI and CD (Continuous Integration and Continuous Deployment) Jobs for build and deployment process.As we are not using any Source Code right now , so keep this as none.
Click on check box Build periodically. This option is used to schedule your job to run periodically.This is generally a Crontab job used in Linux Operating System.
Put 5 starts with space like * * * * * in the schedule box and this means your job will run on every minute.
If you are not familiar with CRONTAB and want to know more about it, read Scheduling Jobs in Linux with CRONTAB.
Step 5- In Build option , click on Add build step and choose Execute Shell. This option will allow you to run a shell script on Jenkins Server.
By using CRONTAB and Shell Script you can automate your day to day tasks or repetitive jobs using Jenkins.
Step 6 – Put the shell script or command that you want Jenkins Server to execute.Here I am putting some basic commands to run on Jenkins server. You can put any script or commands here to accomplish a task on Jenkins Server as well as on a Remote Server.
Some basic command that I put here are
pwd ( This command show you the Present Working Directory)
w ( This command show you the Load on Jenkins Server)
free -m ( This ommand show you memory utilization on the Jenkins Server)
Click on Apply and Save
Step 7 – Now your First Jenkins Build job is created. Click on the job name ” New Project” to see your builds.
Step 8 – Here you can see in the Build History on the bottom left.You can see that the builds are running at every 1 min.Only 5 Build are showing here in Build History as we kept this value as 5 in Step 3.
Click on any of the Build number e.g – #7 , #6 for more details about this build.
Step 9 – click on Console Output to see log of this particular Build.
Console Output is very important for troubleshooting purpose. You can see Jenkins Job build success log / error log and outputs of executed commands /scripts over here.
I hope you enjoyed this tutorial and learned how to create your first Jenkins job. If you think this is really helpful, please do share this to other as well. Please also share your valuable feedback, comment or any query in the comment box.I will really happy to resolve your all queries.
Thank You
If you think we helped you or just want to support us, please consider these:-
Connect to us: Facebook | Twitter
Great content! Super high-quality! Keep it up! ?