Jenkins

Jenkins is an open source automation server written in Java(can be used with any technology). Jenkins helps to automate the non-human part of software development process, with continuous integration.

It works based on plugins i.e. have to install respective plugins in order to communicate. For example Maven, Git plugins have to install with configuration.

Instead of pulling the entire code for building and testing. You can just use Jenkins to automatically fetch the code from repository, build and test it in the test environment and can send an email notification about the results so it will be easier to find the bug in that version of commit, instead of going through the whole code to find the bug.

Advantages of Jenkins

  • It is open source and it is user-friendly, easy to install and does not require additional installations or components.
  • Easily Configurable. Jenkins can be easily modified and extended. It deploys code instantly, generates test reports. Jenkins can be configured according to the requirements for continuous integrations and continuous delivery.
  • Platform Independent. Jenkins is available for all platforms and different operating systems, whether OS X, Windows or Linux.
  • Rich Plugin ecosystem. The extensive pool of plugins makes Jenkins flexible and allows building, deploying and automating across various platforms.
  • Easy support. Because it is open source and widely used, there is no shortage of support from large online communities of agile teams.
  • Developers write the tests to detect the errors of their code as soon as possible. So the developers don’t waste time on large-scale error-ridden integrations.
  • Issues are detected and resolved almost right away which keeps the software in a state where it can be released at any time safely.
  • Most of the integration work is automated. Hence fewer integration issues. This saves both time and money over the lifespan of a project

Install Jenkins


1. Navigate to : https://jenkins.io/download/

2. Download the Generic war files, choose the war file from the stable release
jenkins-generic-war-file 3. Go to the folder in terminal/CMD where you have stored the jenkins.war file and execute below command.


							java -jar jenkins.war			
							


4. You would be able to success screen once we execute the command.

5. Navigate to the url in your browser http://localhost:8080, sometimes a it may take upto 3 minutes to open the page, so have patience if you get no page/ error page.

6. Please navigate to the highlighted path in your browser, and copy the password. unlock-jenkins-selenium 7. Install / select plugins based on your need, you can install plugins after installation of jenkins as well. select-install-jenkins-plugins 8. You may need to wait for 10-15 mins for completion of installation of plugins. installation-of-plugins-jenkins-selenium 9.Fill the use details and continue fill-user-details-jenkins 10. Click on start jenkins button start-jenkins 11. If you reached below page then you installation is successful. home-jenkins

Protractor Interview Questions

Jenkins Protractor Integration

  1. Open Jenkins using http://localhost:8080/
  2. Click on on New Item
  3. jenkins-protractor-new-project
  4. Enter Job Name and and Choose Free Style Project
  5. free-style-protractor-project
  6. Choose advanced options under General section
  7. general-sectionjenkins-custom-workspace
  8. Enter the folder where your protractor conf file is present
  9. custom-workspace-jenkins-protractor
  10. Now Add a Build Step and Choose Execute Windows Batch Command
  11. add-build-step-jenkins-protractor
  12. Provide the command to run the protractor, protractor conf.js. If you have not configured the workspace path then you need to write the command to navigate to the workspace and then protractor run command like below.
    
    								d: # change the driver to d
    								cd D:\Protractor Demo # navigate to folder where the conf file is present.
    								protractor conf.js
    								
  13. Save the configuration and Click Build Now Link
  14. build-jenkins-protractor
  15. Now you will be able to see the execution, under console inside the instance number

Fetch from Repository

Not all the times you will have to run in the local machine because you got to execute the automation in node/slave machines.

In such cases we have to fetch the code from the repository and execute, if your code Java script then you can run directly but if it is Typescript then you need to compile the code(tsc) and then run it.

build-info-jenkins Under Source Management, choose the required tool and then provide the git url and then the branch to clone. git-repository-source-management-git You might need to change the build steps, because this time you should install the npm packages and then compile the code and then execute.


								
								d: # change the driver to d
								cd D:\Protractor Demo # navigate to folder where the conf file is present.
								npm install protractor
								#please do install required, i have limited with protractor to show you
								tsc
								protractor conf.js
								

Jenkins with Package Json

You might have heard about the Maven build tool used for installing the java jar files and update them.

But with javascript we should use package.json file to install npm packages at a shot, please refer package.json tutorial for more details.

package.json file must be pushed and should present in repository

I have set the compilation command in postinstall command inside the package.json. Example for package.json


{
  "name": "cherchertech",
  "version": "1.0.1",
  "description": "this is to showcase the package.json tutorial",
  "main": "index.js",
  "dependencies": {
    "jasmine": "^3.2.0"
  },
  "devDependencies": {
    "@types/jasmine": "^2.8.8",
    "jasmine": "^3.2.0",
    "protractor": "^5.4.1",
    "typescript": "^3.0.3"
  },
  "scripts": {
	"preinstall":"npm cache clear",
	"postinstall":"tsc",
	"test": "protractor conf.js",
	"posttest":"rmdir node_modules"
  },
  "keywords": [
    "cherchertech",
    "package",
    "tutorial",
    "protractor"
  ],
  "author": "karthiq",
  "license": "ISC"
}

When we use package.json, we can write below simple steps to install package and run the code. Repository steps remains same


								d: # change the driver to d
								cd D:\Protractor Demo # navigate to folder where the conf file is present.
								npm install
								npm test
								

Learn to create package json

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions
  • Sowjanya
    Hi KarthiQ, 
    
    i have gone through the protractor material you have provided and that is awesome. Actually i am working on protractor with minimum knowledge since i have not come across such scenarios to lean more. But now after reading this tutorial i am confident enough to handle any scenario. Thanks a lot.
    
    i got confused in one area that all the examples given is in only typescript?? do you have any material with only javascript ? 
    Reply
    • Author
      Sowjanya,
      Code for Javascript is same except where I used class keyword
      Reply
      • Sorry KarthiQ, I did not get your answer. Can you please elaborate.
        Reply
  • Protractor Training

    new tutorial I am starting new Protractor training batch on Weekends. It is two days course from 01-june-2019 to 02-june-2019 based on class room (BANGALORE)

    Interested people can confirm the seat by calling to +91 8971673487 or whatsapp to +91 9003381224

    Find the course content : View Content