Selenium Integration with Jenkins and Github

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey hi everyone this is Mukesh once again from blown - at amazon.com today in this video we are going to talk about how you can integrate your selenium script with Jenkins get in github so in the last videos we have seen how you can upload your framework on github how you can create a maven build but till now we haven't integrated our scripts with Jenkins so how Jenkins will connect your github account how it will clone the project how your maven build will run and how finally you can run your test via Jenkins so this video will talk about complete end-to-end picture about all these bits and pieces which we have so it will connect everything and it will run so let's talk about what exactly we will discuss today we will talk about how to install Jenkins how to do the basic configuration of your Jenkins how to setup the email configuration the required plugins how we can create connection with github how you can create builds so when you say build is nothing but what exactly your Jenkins will do what your gel job will do will also talk about what is possible actions so once your build is done what I exactly want to do so they will talk about post collections and the most most important part called parameters in the previous videos we have seen how you can pass parameters from test engine then we have discussed how to pass parameters from maven now how we can pass a parameter from Jenkins that is the main point so when you trigger your Jenkins build it will pass this parameter to your maven build maven build will pass your parameters to your actual tests okay so let's see how to install Jenkins this video we already discussed the same part how to integrate ceiling with Jenkins almost three years back ok that time Jenkins was Jenkins 1 dot X so we have seen how to integrate Jenkins 1 dot X with selenium now after almost like last year they have launched Jenkins 2 and the complete UI has changed some setting has been changed and some configuration has been changed so many people are facing issues with the latest gen so this video is only on the Jenkins latest version and the selenium latest version which is currently selenium 1.1 3.14 and Jenkins is two dots X we'll talk about the different versions which we have currently for the Jenkins so if you are completely new to Jenkins like how this Jenkins work what is Jenkins Waterside want is disadvantaged I would recommend you to watch the initial few minutes of this video so that you will get to know about Jenkins in this video we are going to talk about how you can download the new Jenkins and how you can configure for selenium and how you can trigger your selenium scripts as well okay so the first step you need to download the Jenkins ok so just type download Jenkins you will navigate to Jenkins official website here you will get two options okay one you will get LTS which is long term support one is the weekly release I would highly recommend you to go with the LTS versions because there's table one here if you come back you will see the past releases as well let's say in case if you want to go back to the previous versions and you want to download some previous versions you can download from here for the time being I will download the latest one as of now the latest version is 2.1 38.1 and this video is based on Jenkins 1.6 here you will get multiple options okay if you are looking for darker and different operating system like Mac OS you window you can download from here as of now I am working on Windows either I can click on windows or I can click on download generic who are fine both options are same I will click on this generate Java package you can see it is downloading when var file it is going to take so much time so I will cancel this I already have this VAR fight downloaded which is the latest one which I downloaded it almost one hour back this I will install in my local system installation is quite easy first step you need to open a command prompt and you need to deploy this VAR file when you deploy this fire file Jenkins will start in your local system okay and then you have to do the basic configurations now a few small things which we need to notice here like by default Jenkins try to run on eight zero eight zero port number but in my system eight zero eight zero port is already occupied so I cannot use this port number so I have to change the port number so in order to change the port number I have to use one keyword called HTTP port two - esta TP port P is capital and which ever port you want so I will install the Jenkins on eight zero eight four so what is the command to deploy just type Java space hyphen jar you can use this var file and you can use same s TTP port equal to eight zero eight four guys just remember if you don't want to change the port you just give till Jenkins dot waar and hit enter and if your port is free it will start if your port is busy you will get one error message that yes this port is already binded so let me show you that error message as well given a hit enter if this port is free it's ok otherwise it will throw error message then we will change the port you can see it is giving me one error message and if you just try to look at it it says binding at section already have a dress in use ok so I will also give space - hyphen s TTP port B is capital equal to 8 0 8 4 you can use eight zero eight one eight two eight three eight four in math system 8 1 a 2 a 3 or occupied so I am going to use 8 0 8 4 and now it will take couple of seconds to start and good thing to notice when you try to run the zenki's it goes to your user folders current user in my case it goes to my current user and you can see it will create a directory here called dot Jenkins this is the most important part which you need to remember all the settings whatever task you will do it will come and store whatever jobs your plugins your credentials your configuration everything will be stored in your dot Jenkins file ok now you will get one message Jenkins is fully up and running it means now the Jenkins deployed your local system so just try to hit this URL localhost colon 8080 for and hit enter ok now this was not there previously in Jenkins 1 ok it used to start directly but in Jenkins 2 you need to unlock the Jenkins it's very easy it directly says that Mukesh currently your initial admin password is available in this directory so what we'll do we'll go directly and just open this location it will open one like it will show me the initial password ok this is the initial password I will simply copy and I will paste here and click on continue okay now you will get this error message sometimes it's not that you will always get this error message like your Jenkins's offlane try to download skip this configuration part or you can configure the proxy okay so if you are working with an office network you can go ahead and set the proxy settings but if you are working in a home network let's say I am just showing you this demo so I have to do a small dirty thing in my configuration file which will make marriage and kids up and running there's some a small issue or I will say a bug in the Jenkins like if you try to work in your local system without setting proxy it gives you this offline message so I will show you what changes you need to do in case if you are not getting this message it's perfectly fine you can continue with the remaining steps this is only when you get the offline message so what changes you need to do you need to go back to your Jenkins home directory which is nothing but this folder which I showed you just now and here you will get one file called hudson dot model dot update center so you need to just open this file okay you can open this in a notepad plus plus so that it comes in a standard format okay okay just let me close it and open it again you will see this what it does it try to update your Jenkins your plugins from this particular URL so what we need to do we need to go ahead and remove this s okay by default it downloads from HTTPS just we are changing HTTP to HTTP and just save this file okay and you need to restart or Jenkins guys this step is mandatory only when you get this error message if you're not getting this error message you can continue with the normal steps I keep getting this error messages okay so that's the reason I found the solution which I shared with you in case you are also getting the same thing just you remove this HTTP and use - d/p and now you will see again it says Jenkins is fully up and running I will just refresh this again it will ask me the password so no worry I will go ahead and give the initial password once again in case how to stop the Jenkins just press control-c and it will stop the Jenkins okay in case if you're not getting the previous error message you will directly land on this page which says install suggested plugins or you can select some plugins based on a requirement I would highly recommend go ahead and download or click on this option it will download all the suggested plug-in which we use almost on the daily basis ok now it will take some time almost 10 to 15 minutes ok and all it will try to install all these plugins in case few plugins are not getting installed we have to install them manually but if these plugins are getting installed that's good enough ok so I will pause this video for a while and we'll resume this once all the plugins will get installed ok so once all the plugin will get installed ok you will get this screen automatically where you can create the admin users ok this is up to you whether you want to create or not or you can continue as admin directly using this link but I would highly recommend you to create certain users because in Jenkins 2 they added some security features as well where you can create and maintain multiple users and you can assign the roles as well like what each user can do ok so what I will do I will create a user called selenium underscore 50 and my local system and I will just give these details ok my full name my email address and this username password selenium underscore 50 and I will say save and continue and finally it is asking you if you want to change the configuration as of now I want to run on localhost colon 8080 for if you have time just go through this documentation part okay you will get to know what exactly they're talking about so I will say start using Jenkins so let's wait for a few seconds and you will get the Jenkins home screen and whatever things we are doing okay it will also show you on your command prompt like it installed all the plugins right so it's its installation successful familiar all the plugins which we downloaded you will see all the activity on this command front as well it is taking longer than expected so let's refresh this okay just a minute okay let's wait for a few seconds [Music] okay so it seems it is not working so let's restart the Jenkins sometimes you will also face the same issue suggests a control see it will stop the Jenkins and now just hit the enter understood all the plugins okay since it's an open source they keep making changes they keep releasing the new functionality so you might get couple of issues but restart always works for me so I'm just giving the same username password which we just created a user now and now we are getting logged in okay and you will see this dashboard with my user okay you can customize based on the user which you create now it's all done it's up and running but we need to give certain path so that Jenkins can recognize where our software's or our applications are located right so before we start you also will find one rest api section okay where you will find all the api switch you can use okay and this is the Jenkins official website now in order to configure your Jenkins just click on manage Jenkins as of now we need to tell our Jenkins that go and check Java in this location because anyways we are going to trigger Java projects plus we also have to tell maven location because we also have to do the maven configurations as well right because we need to run maven projects as well now there are two options one is configure system and global tool configuration so click on global tool configuration where we will mention all our tools which were going to use click on add JDK and check this option if you check this option it will keep downloading the latest Java version which is available in the market you can see it is trying to download Java 10 alright and currently I am running Java 8 so if I check this option it will download the new version which I don't want you can uncheck this option and just type Java underscore home and give the home directory ok so I will go back to my computer property add one system settings in our main variables and okay here I have not said yet so I will go back to my C Drive Program Files Java and this is my home directory which is JDK 1.8 dot 0 underscore 40 ok that is done we also use git in upcoming videos ok as of now I need maven as well so I will click on maven again in the maven you'll get the same option that you want in install are not automatically or one of these versions I don't want I want to give my local maven which I installed in my system so I will say maven underscore home and currently my maven is located at this location ok so if you're not familiar with maven then I already have a video on maven how to install maven I will give the link in the description which you can refer and that's all ok it means now our channel case is configured with the tools which we are going to use we will also set up the email notifications ok so you can set the email notifications we just here okay so you can see here we'll get one option email notifications okay so we'll set this as well in the next video as of now we are doing the basic configuration so that we can trigger we can run our jobs now let's click on create new job here you can see multiple options okay like freestyle project pipeline project folder organization pipeline as of now just to check whether everything is working fine or not we'll create our first job okay and let's click on Crystal project and click on OK now we need to just give see this is optional part but you can also give like this is my demo job and you can see here we have source code management in case if you want to download from the gate and other subversions you have built trigger option where you can set how you want to trigger your build okay build environment and main is the build option make which kind of bill you have do you have a bad command shell command and command Gradle script since we it's a demo job we are going to run a small command called Java ha - version which will simply print my Java version I can add n number of bad commands or build so I will also add one more batch command called ambient version ok and this is the post production it means once your builders done what you want to do do you want to archive their results you want to publish the result you want to send email and they will email whatever activity you want to do you can do in the post build actions we will do the same thing in upcoming videos as of now let us run this ok save this and click on build now what it will do it will build your project ok and it will trigger the build which you had given so first build step which you had given Java space hyphen version it is printing my Java version in the next we have given MV in - version which is also working success build success okay now you will see it's working fine now just to show you one plugin okay if you come here even see manage plugins you will see three four options okay one is update in case if you have previous plug-in and new update is coming you will find enough updates available section whatever possible plugins are available it is already listed here so there's one plugin called green balls what exactly it will do it will change your build color okay like say if it is fast it will show you green as of not says blue so few people don't prefer blue color for past jobs so it's not mandatory anyways it's optional but I like this plugin so I use almost every time whenever I use Jenkins okay let it install these are the dependent plugins which we have set is also downloading windows slave and one external monitor job type plug-in and finally it's success okay so let's run this again and see okay it's still giving gloom maybe we have to restart our Jenkins okay then it will show you so quickly I will put control C and again I will restart my Jenkins it will take few seconds and again it will start my Jenkins okay just now I restarted my Jenkins I refreshed and you can see now for every success you will get built with green color okay optional but very a useful feature now Before we jump into how to trigger selenium script one most important part is the view let's say you have multiple jobs created in your local system and now you want to categorize what so you can create a view in one view you can create or put multiple jobs you can treat another view so you will have clear segregation of all the jobs which you have created on your Jenkins so you can see you can click on plus option it will ask you view name let's say I will give smoke scenarios you can also give smoke scenarios entrance scenarios or you can give the project name as well for multiple projects you can create multiple views it's up to you how you want to segregate let me just segregate this based on project name so we have one project let's say orange HRM so I will click on list view and I will select with jobs as of now we have one job only it is giving just one job and now you can see one view is created this is all view all the jobs will come here but if you create multiple views the option which is selected only that jobs will come okay now since our first job is working now let's trigger one selenium project via Jenkins now this is silly Jenkins already which is up and running and this is the job which is already pre country good now this is our framework okay and last week we have loaded you can say seven years back and recently in the previous video we have done some changes so let's push these changes and then we will connect Jenkins with github so what I will do I will copy paste or I will select all files and I will make them as stage changes again I will put a comment and finally I will say adding few new lines or new code and again okay finally let's do a commit and push okay so what is same cannot connect okay let's do a quick Drive push first try run failed just a second let's do a poly fast okay nothing to push pull and just to push okay there's something wrong with the configuration I guess it says cannot connect to another possible so guys there was some issue with the login credentials because I have logged in with two different accounts on the same github site was creating issue so I just removed one of the credentials now let's drag in so previously my default is turning my gmail our ID so when I was changing it it was not reflecting as I kept configuration so I have to change directly from the settings I will show you how you can change it and now it is taking the default which is my official learn automation ID and I will say new code changes okay let's do commit and push now [Music] and you can see these changes updated now now what was the issue like I said earlier we had I have two accounts okay so I have configured this account as well so you can click on add entry or else you can open this get config file which will open in the backend and you can add your multiple accounts okay and some time the issue which should get in like it not permitted in that case you can clear the credentials okay or you can change the credentials because some time it takes your different credentials then it says you are not permitted to push so you can clear the credentials okay and then you can net the new credentials for your new account and then do the same push because in case also you have multiple accounts you can make the changes and run it now we have updated code okay if we just refresh this okay a few minutes ago it is showing you the new changes in if you open our framework convert XML yeah we have all these parameters okay now let's create a new job okay and you can create a maven project guys by default you will not get maven project if you need this maven project option you need to download one plugin okay that plug-in name I will tell you it's a maven integration plug-in so if you go back here to manage plugins and right now I have already installed in your case it will come in the available section I will tell you the plug-in name just go to install and this search for maven can you see this plugin called maven integration plugin it is already installed so it is asking me to uninstall in your case you will find in available section just install this and you will get this option called maven project by default it will not come cute or let me give a proper name called regression test I will select a maven project and I will click on OK now if you want you can give some description okay I will say this job will run all the regression test okay now you can okay if you don't want to give get you can give the direct path of your framework okay so let's see if you want to directly run locally so what you need to do you need to provide the location okay so what I will do I will go back to my project this is our framework go to the property this is the location I will copy path till here okay and paste now when it comes to goal we need to provide what goals you want to provide so I will give this goal as clean install and we need to pass three parameters right so - D one is browser which is nothing but your Crowell - D okay let's see one by one let me hard coat this and then we will parameter is using Jenkins parameter just to check whether tests are working fine or not I will pass all these manually because it is STP as colon double slash classic dot CRM Broadcom slash index dot HTML and - D XML files as of now we have one XML file which is destined G dot XML file that's all so it will go to this location eat up the poem that XML run this cleaned run this install with these recommand and it should run my tests right now let's click on save and let's build this job ok you can click on this progress bar ok or you can click on this build icon it will navigate you to the console and it's very straightforward we haven't done any changes just we given one permission to Jenkins that go to this poem that XML and run it that's all so whatever task you were doing some command from now Jenkins is doing for us but this is not the ideal case this is not the actual real case how we work right because again we are dependent on particular system our task is it should automatically download download the code from this github then run it so in order to do that you need to click on this clone option again for cloning we have two option when it's ssh one is HTTP so i will talk about ssh in detail in the either in the next video or after this mister dps you just copy this you can see this option calls source code management click on gate you can provide the repository and you can see it is asking give me the credential if I give credential is none how it will identify that this Jenkins is authenticated like this request is coming from the authorized user so you need to also add your configuration in the genican section where you can pass username with password and if you have some other things like docker host certification who certification secret file certificate just select username password and give the username my username is here okay short one II and password is which I had given already and description I will say official account ok this description is actually sometime helps me to identify you can see this description will come additional then I can understand now what it will do it will download in a local system so now no need to hard code this now a small heck here or I will say you can see it is not able to find format xml and which is quite obvious because you have to move the file no when you download this code wait when it will clone this it will download your local system and it will download something like this ok so when you see the download code will look like this but if you see the actual own that XML is located under framework folder right so what we will do we will just go ahead and tell our Jenkins that first go-to framework folder then try to run this bounded XML okay let it be because it is not able to find once we run it it will clone then only it will list down okay and in case any changes required we will do let's save this and let's build this now it should ideally clone the project and you can see it is trying to clone from github.com okay so Tony framework Todd kit since it is downloading first time it will take few seconds and once it will yeah you can see all everything is done now and everything is working smoothly okay so based on our consecration it took the data from github it executed my test and it will show you the passing field now the changes which we need to make here okay so let's say somebody wants to run the test on different browsers again person has to come here change the browser change the URL or change the XML file so again people have to come to configuration build and then they have to make changes which is also not a good approach right so anything can be done yes you can select this option called this project is parameterize and you can pass parameter so let me show you one string parameter where I will say please pass the application URL and if you want you can keep some default URL like in case user don't provide then this will be the default URL okay so better I will copy paste okay and here you can give the description like what exactly this parameter is so you can give your please provide application URL which is getting tested which you are going to test now string parameter is just normal string parameters but let's say if you want to give multiple options then you can also select choice parameter like browsers so we have three browsers as of now in our framework right so we have Chrome we have Firefox and we have IE and you can also give a description that please select which please select browser for your test and the last option as we know we have XML file so again you can select string parameters in the string parameters I can give XML suite like which XML suite you want to run I will give default test engine wrote XML default means and when you don't give this value it will take my default but user can change it and we can give here that please select which tests seat you want to run if you want you can also keep this as a choice parameter but not required now how to make connection because anyways we have hard-coded here so whatever you you give doesn't matter so we need a connection right so what we can do we can copy this key come back to your property a dollar and whatever key you are selected on top okay let's say you want to pass browser so just come back to this and go back to your build and make dollar browser same thing we can do here like which XML suite you want to run and followed by dollar dollar and whatever value you have T we have given same for other now click on save and previously it was coming build because we were not having any parameter but since we had it parameters you can see well with parameters where it will ask you which about the browser to select which XML speed you want to select and what application and you can see these are the description which we have given but if you want to change change this URL so at runtime like now user have the flexibility like they can pass runtime with XML suite what application which browser they want to test if I just build this you see it will first do this cloning part and you can see it is updating here we can see so it will run this clean install it will pass our parameters ok and finally it will trigger our test ok there's something wrong with the xml friends i guess it says URL test URL to be test as required by before class ok so just some small changes URL to be tested ok so what we did we actually missed one space ok so this is very important to find where to fix what to fix is the different thing where to fix ok so it will come slowly timer time to experience ok so what we identified that one parameter was missing so we went to the parameter part and we found one space was missing and now it is local as expected okay let me run the same build okay it's still one build is running if I run one more build with Firefox okay let's change is to Firefox and run it again okay so it is running already one build is running so this build is in queue and now that build executed the second build is running and this should start in Firefox is as expected Firefox okay build a success our test completed and you can see this already giving you the print result this comes by default when you have more than three build history now let's talk about the post bill action okay so in the post production you can see I can do many things okay so sorry do not do the poor step go to post build first is I need to publish the test change your results so keep it as it is and click on save now apart from this I want to send email as well now in order to send email you need to a small jenkins configuration so just go to manage jenkins go to configure system if you come down here you will see one option called extended email notification so these are the google details i have added my gmail account details in case if you have any others email server you can configure it if you are working with an organization you can get this d little from the admin team IT team or from the another team member who is already having these details just enter the SMTP server details email suffix SMTP authentication username password if you want to travel just give the same details just replace this username password with your password use SSL and port number is four six five and now a very important part when you configure this extended email notification you can change the template when I say change the template means you can change the default subject I can say like learn automation report so every email should come like learner to mission report - whatever your project name okay let's say project name is regression test it will come regression test build status pass or fail and default content I want to print like but say hey eighty members or whatever this is automated email please do not apply or say you can give any name or any content like below just execute it please find the summary by default they have some text you can override it okay it will automatically replace at runtime will URL project name and you can give things from okay so these are the default content and you can also add the triggers to gosh I will show you when to send email and if you want to test the email part just to check whether all the settings working fine or not just give the same settings and click on this check box and you just try to send a configuration test mail if this email is sent from Jenkins it means all these configurations are working fine okay so in the same way we have extended our we have done the same setting for extended email notification click on save and we are done so again go to post build action apart from this I want to send email okay so you can see one more option called editable email notification where it will send to the default guys which we have set default recipients as of now I want to send to myself so that I can show you in the video I will just add gmail.com the rest everything I will remain same the default subject default content and the most important part Advanced Settings when you want to send this she can see right now the trigger is set to only for failure and sent to developers I don't want this I will add my own trigger that it should always send one email to the recipient list you can also set the trigger that you want to send only first we'll failure ii will failure fixed not build you can change to any status i want to send always one email and to the list which i have given in my job okay and let's turn this again you can also run the same thing using rebuild last so this is one option which you will get in jenkins and yes so in the last build we have set Firefox so it is running on Firefox and once everything is done it will send an email as well okay so let me do a small recap what exactly we have done for this video so we have created a complete environment where we have thousands ngenikis this Jenkins is taking data from cricut and github so we have a git and github so from get we have sent the data hub so Jenkins will download the code from github download or local system and if the local system we have set up a maven build this maven will is running some sort of destiny dot XML file and this destiny dot XML file is running some tests okay so this is how the cycle is running Jenkins is talking to github github is downloading the code to local system it is triggering one maven build and may will build is running our tests okay so you can see now tester is triggered it is successful and it also sent email to my gmail ID I will show you that email okay and the previous you can change whenever you want whatever conditions you want you can just change the triggers and to whom you want to send it also you can see because I will show the email this is the publishing destiny result in the next video we'll talk about how you can publish your extent report as well okay that is the next task what you can see now everything is working as expected and now it is your task to add more and more test cases okay create test engine at XML files using page object like create more tests using page object model convert them into xml files and run this and finally push the code to github and run these xml files or run that build by Jenkins okay so this is what I have for today so in the next video we'll talk about more about Jenkins publishing the question report and so on and we'll talk about some more important plugins okay which can help you which can increase your productivity as well okay so I hope you can like this video if this video is helped give you or if you get something new up from this video then please like my video subscribe to my channel and share with your friends and colleague who are looking more about Jenkins and test automation that's all I have for today we'll see in the next video have a nice day bye bye
Info
Channel: Mukesh otwani
Views: 39,496
Rating: undefined out of 5
Keywords: Selenium, Jenkins, Maven, Git, github, Selenium Integration with Jenkins and Github
Id: gT9qnZi3f74
Channel Id: undefined
Length: 49min 49sec (2989 seconds)
Published: Tue Feb 12 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.