Jenkins Beginner Tutorial 4 - How to use CLI (command line interface)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hello and welcome to this session on Jenkins This is the fourth session of the series and today we are going to see how to use the command-line tool for Jenkins and how you can control various actions on Jenkins without a UI and using it a command-line interface Okay Now the very first question is why should I move to the command line? Right? I can do all the things from the UI of Jenkins So why should I even bother to go to the command line and do all the actions? So the reason for going to command line is it is easier it is faster and more convenient it you will also have to worry about the memory management Right? So it is more efficient if you go to command line because it will consume less memory than the UI and then of course the continuous integration when you To do a continuous integration or set up a build process Then you will have to go to the command line And that is why we have to use a command line interface for Jenkins. Okay now mostly it happens Is that the beginners for any tool after getting some good basic understanding the move to command line, but we are having this session as a fourth session of this series and this is because if you are automation engineer or if you are a developer or a software engineer Whatever Whenever you start with a new tool always try to look for the command line integration of that tool and it is very easy and convenient to have a command line execution and control over your tool Okay So let us begin and it's going to be very easy in three or four basic steps I will tell you how exactly you can get started with command line of Jenkins So step one is Start Jenkins, and we will do the same thing as we have learned in our last sessions If you are on Mac, you will go to terminal If you are on Windows You can go to command line and you have to go to the location of your Jenkins.War So I will go to my location of my Jenkins.war and it is at desktop Tools Jenkins Okay, and then we have to say Java - jar Jenkins.war and this will start my Jenkins on the default Port which is 80 80 in case you want to change the port you can say - - HTTP HTTP port and whatever Port you want to start Jenkins own Okay, as of now, I just want to start it on the default 8080 Port so I'll just click enter And it will start my Jenkins Okay, so let me go to my browser and go to localhost 8080 So my Jenkins is getting started Okay Now my Jenkins should be fully up and running and yes, it is up Okay So now what we have to do is you have to go to manage Jenkins here. Okay, so I will also write it down step two is go to manage jenkins and then you have to go to configure Global Security. Okay And here make sure that this enables security is checked Okay, apply and Save so this should be checked Okay Enable security Sorry okay Now what we can do is s step number three, what you can do is whatever you URL is for example Mine is localhost 8080 you put a forward slash and say CLI Okay, so I will say go to CLI, so this portion the first portion can be anything as per your system It can be some IP here instead of localhost and can be any port whatever your Jenkins has working on You just have to append CLI here and as I will do this you can see the Jenkins CLI window comes up Okay, and here they have given a Wiki So if you want some detailed information, you can go to their Wiki and you read this Jenkins wiki for CLI Okay and then they have given this URL to download the jar and you can just click here and your Jenkins CLI jar will get downloaded. Okay, so what you have to do is step four is download Jenkins CLI jar and place at any location on your system. So whatever location you want to run the build commands from you can save this jar to that location Okay, and then what to test the jar is working right now we have to step five s test the jar or you can see Jenkins command line is working What we have to do is go to your location wherever you have placed this jar file Okay So for example, I will go to my terminal in Windows You can go to your command prompt and go to the location where ever Your Jenkins CLI jar is placed So I have placed my Jenkins CLI jar here inside tools Inside Jenkins desktop tools Jenkins and I have created a folder Jenkins CLI, and I have placed my Jenkins CLI jar here So I will go to this location from what from the terminal Okay So tools Jenkins Jenkins CLI Okay, and now you can see they gave us this direct commands and this UI is very intuitive I have started my Jenkins on localhost 8080 So it is giving me the same URL here If you start your Jenkins on any other port or IP It will display that Port and IP Here So what you have to do is we just have to copy it from here and test on your command line autumnal So I'll just copy it from here place it here and then drag Okay If you get the same thing then what you can do is if you do not know your passphrase You can go to Your Jenkins and whatever user you have logged in as it will be displayed here in the top right corner Go to the drop down and go to configure And here you have assessed public Keys here, you can set any of your public keys or any passphrase Okay, and the same pass phrase you can use here if asked for. Okay So see I just ran that command and I am getting all the possible options. Okay, so it is also given here so you can do all these things You can add a job You can do a build you can do shut down restart and so many other things right So let us test it and let us do a safe restart So if you can click here, you will actually get the command in again This is very intuitive Will actually give you the exact command for your instance So because I am localhost:8080 It is giving me the same URL here So I'll just I can just copy it from here and go to my terminal paste it and run the command Okay, did you notice it is saying me it is giving me some error Anonymous is missing the overall administrative permission Okay So in that case, what you can do is you can go to manage Jenkins configure Global Security and here in the authorization I am just changing anyone can do anything just for the session I want to test and I am saving this and let me run the command again and yes now it is restarting and you can see the on the window with Jenkins I had started it is saying restart in 10 seconds it is going to restart my jenkins now ok so jenkins is stopped and now they are restarting it yes now the jenkins has started ok there are a lot of other options and you can do almost all the actions like building a job or adding a job deleting a job and so many other things right installing a plugin is also there install-tool is there right so in the coming sessions we will look more deeply into command line interface and what all we can do for the session you should be just be able to get started with command line and then you can do some hands-on than you know keep playing around with command line so that you can get more knowledge happy learning hope you like it thank you.
Info
Channel: Automation Step by Step
Views: 253,108
Rating: undefined out of 5
Keywords: jenkins cli, jenkins-cli.jar, jenkins commandline, jenkins command line, jenkins command line interface, jenkins cmd, jenkins how to use cli, jenkins how to, jenkins how to use command line, run jenkins from command line, jenkins beginner tutorial, jenkins basics, jenkins inroduction, learn jenkins, step by step jenkins, my jenkins, jenkins, jenkins easy, why jenkins, how jenkins, what jenkins, where jenkins, jenkins step by step, learn jenkins from scratch
Id: ooA8RS3hC6k
Channel Id: undefined
Length: 11min 23sec (683 seconds)
Published: Sat Sep 03 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.