MainMenu

Home Core Java Overview Maven Tutorials

Friday, 24 November 2017

Selenium Integration with Jenkins Tutorials 1




For Video : CLICK HERE For Video Tutorials Playlist



Jenkins Introduction :


OPEN SOURCE AUTOMATION SERVER which can be used to automate all sorts of task such as Building, testing and deploying Software.
Jenkins is a powerful application that allows continuous integration and continuous delivery of projects, regardless of platform you are working on.
It is a free source so it an handle any kind of build integration.

Why Jenkins :


It is Easy to Install.
It has a lot of plugins which make task Easy.
It is build in java so it is Portable to all the major plateforms.
Jenkins is a software that allows continuous integration.

What is flow in jenkins :


Developers check their code & made changes as required
Jenkins will pick the changed source code and trigger a build and run any tests if required.
The build output will be available in the jenkins dashboards, automatic notifications can also be sent back to the developer.

What is continuous Integration :


Continuous Integration is a development practice in which the developers are required to commit changes to the source code in a shared repository several times in a day or with regular interval.
After that a job will get triggered by jenkins and create build.
This concept was meant to remove the problem of finding later occurrence of issues in the build lifecycle.

Here is the work flow of the CI :




What is continuous Integration ?

Continuous Integration is a development practice in which the developers are required to commit changes to the source code in a shared repository several times in a day or with regural interval.
After that a job will get triggered by jenkins and create build.
This concept was meant to remove the problem of finding later occurrence of issues in the build lifecycle.

on other hand you can say CI is just : Build & Test


Use of Continuous Integration

)1. : Automate the Build
)2. : Make the Build self Testing
)3. : Keep the Build Fast
)4. : Everyone can see what's happening.
)5. : This allow the team to detect the problems early.

Other Tools which support CI :


Jenkins
Teamcity
Go CD
Bamboo
Gitlab CI

Workflow in continuous integration




Before Continuous Integration :
The entire source code was built and then tested.
Developers have to wait for test results.
No Feedback

After Continuous Integration :
Every commit made in the source code is build and tested.
Developers know the best result of every commit made in the source code on the run.
Feedback is present.

Download Jenkins : Click here to go to Download Page

Download Jenkins for windows : Click here Download zip file

Download Jenkins : Click here to Download war file

Now download and install the jenkins in your machins task is done.

After that you will get below window



You need to enter the password present in appropriate location.

Jenkins will ask you, whether you want to create a user or continue with admin user
for admin user username & password will be admin
but in my case i will create a user so below window will appear



I will fill the required details & click on the next button after that below window will appear to install the plugins, your can select the plugins as per your need or you can select the default option which is install suggested plugins




It will take little bit time and after that your jenkins dashboard will appear at the location http://localhost:8080



Alternatively you can also install the jenkins in your machine using war file & cmd.
Open your command promt
navigate to jenins war file location using cd etc basic commands
not type commandjava -jar jenkins.war and hit enter key as below in image


congratulation jenkins is not installed in your machine.



How to Change port number in jenkins?


There is only one line commond to change the port number in jenkins :
java -jar jenkins.war --httpPort=8081

How to restart the Jenkins?


There is two ways to re-start the jenkins :
1): from browser :
write the below commond & hit enter
http://localhost:8080/restart

2): In windows machine :
Press win + r
type services.msc
find the jenkins & right click on it
There will be restart option , just press on it

Why do we need to change the home directory in jenkins?


1): Due to less space in user directory.
2): Due to project requirement.
3): Confliction with other app.

How to change home directory in Jenkins ?


You need to follow some couple of steps to change the home directory of jenkins :
1): Find the existing directory of jenkins
generally it is inside C , User directory & in my case it is :
C:\Users\chandan.singh\.jenkins
OR
from jenkins, you will also get Jenkins home directory
http://localhost:8080 >> manage jenkins >> Configure jenkins >> First option will be home directory

2): Create a new folder, where you want to have the home directory.
in my case
D:\Automation\Jenkins_Home

3):Now copy all the data from Old directory by pressing "Ctrl" + "A" and paste ("Ctrl" + "A") in new directory

4):Now change the Environment Variable

5): My computer , right click on it & select Properties
and select Advanced System setting
a pop will appear , click on Environment varable
under system variable find JENKINS_HOME & click on Edit button
Note : (if not available then click on Add button & add this as below image )
In path enter the new directory path, in my case it is
D:\Automation\Jenkins_Home
click on OK & OK
Now restart your jenkins & check the new directory.


Configure Email Smtp server details :

Outlook.com SMTP Server Settings

Outlook.com SMTP server address: smtp-mail.outlook.com
Outlook.com SMTP user name: Your full Outlook.com email address (e.g. myname@outlook.com, not an alias)
Outlook.com SMTP password: Your Outlook.com password
Outlook.com SMTP port: 587 (you can use port 25 as an alternative)
Outlook.com SMTP TLS/SSL encryption required: yes

Yahoo SMTP Server Settings

Yahoo! Mail SMTP server address: smtp.mail.yahoo.com
Yahoo! Mail SMTP user name: Your full Yahoo! Mail email address (including "@yahoo.com")
Yahoo! Mail SMTP password: Your Yahoo! Mail password
Yahoo! Mail SMTP port: 465
Yahoo! Mail SMTP TLS/SSL required: yes

Yahoo! Mail Plus SMTP Server Settings

The SMTP server settings for Yahoo! Mail Plus accounts (which no longer exist) were:
Yahoo! Mail SMTP server address: plus.smtp.mail.yahoo.com
Yahoo! Mail SMTP user name: Your Yahoo! Mail user name
Yahoo! Mail SMTP password: Your Yahoo! Mail password
Yahoo! Mail SMTP port: 465
Yahoo! Mail SMTP TLS/SSL required: yes

How to schedule the build in jenkins

Jenkins scheduler watch work on Cron Time Format.
What is Cron : a command to an operating system or server for a job that is to be executed at a specified time.



For Example : i want to run my build on 10:06 PM on 15 Jan then my command/time format will be :-
06 22 15 1 1 (Refer the below screen)
Explanation : in above time format 06is for Minute, 22 is for Hour, 15 for date of month,1 for month of year & 1 for day of week.

Jenkins Dashboard >> Click on your project >> Click on Configure >> Go to Source code Management Tab >> Under the build Triggers >> click on Build periodically checkbox >> In the Textbox input your schedule time in cron time format
Refer the below screen :







Tags :

How to change directory in jenkins

How to change port number in jenkins

How to restart jenkins

How to send emails from Jenkins

How to send emails when build is success

Send build success email from jenkins

What is Jenkins

Selenium Integration with jenkins

jenkins tutorial 2017

What is continuous Integration?

What is use of continuous Integration?

How to schedule test with jenkins

How to schedule test with jenkins in selenium

Monday, 6 November 2017

Java 8 Stream Filter with Example


Hello friends,

In this article we will discuss about Stream Filter in Java:


For Video :- Click Here



we will provide java 8 Stream filter() example.
We filter a collection for a given Predicate instance. filter() method returns a Stream instance which consists only filtered element on the basis of given Predicate.

As the name says , Stream, means which is flowing continuously like data in list, and we want to filter some result from this list as per your need.
By below example this will get more clear.
Code :


import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

public class Swap
{
public static void main(String args[])
{
List list = new ArrayList();
list.add("chandan");
list.add("adhiraj");
list.add("Akshat");
list.add("Anant");
List names = Arrays.asList("aviraj", "angraj", "devraj", "dananjay" );
list.stream().filter( u -> u.startsWith("ch")).forEach(System.out::println );
names.stream().filter( u -> u.endsWith("aj")).forEach(System.out::println );
names.stream().map(u -> u.equals("aviraj")).forEach(System.out::println);
}
}


OutPut:

chandan
aviraj
angraj
devraj
true
false
false
false


Code Explanation : First we create two list with name list & names then we will add some records in the both list.
then simply we will apply , Stream() method on the lists & filter() them as per our need.
finally we will print the required string.


for more deep knowledge :
Click here



Tags :
Java 8Stream
FilterStream filter with example

Saturday, 4 November 2017

Scanner class in java with example


Hello friends,

In this article we will discuss about scanner class in Java:

Scanner class is used when we want Input from user.
In our example, we will take the name & age from user as input & will print these values.

For Video :- Click Here



import java.util.Scanner; public class Swap
{
public static void main(String args[])
{
Scanner scan = new Scanner(System.in);
System.out.println("Enter Your Name");
String mystring = scan.next();
System.out.println("Enter Your Age");
int mynumber = scan.nextInt();
System.out.println("Your Name is :"+ mystring);
System.out.println("You are" + " "+ mynumber+ " " +"years old");
}
}

Output : Enter Your Name
Chandan
Enter Your Age
28
Your Name is Chandan
You are 28 years old.





Tags :

What is Scanner class in Java

Example of scanner class in java

How to take input from user in java

How To Swap Two variable without using third variable in java


Hello friends,

In this article we will discuss about swap variable without using third variable:

For Video :- Click Here



public class Swap
{
int x = 10;
int y = 15;
public static void main(String args[])
{
Swap object = new Swap();
object.g();
}
public void g()
{
x = x+y;
y = x-y;
x = x-y;
System.out.println("After Swap Value of y : " + y);
System.out.println("After Swap Value of x : " + x);
}
}


output :
After Swap Value of y : 10
After Swap Value of x : 15

Code Explanation : Suppose we have two variable x, y and they have value 10, 15 respectively and we want to swap these two variables value.
HOW IT WOULD BE DONE ?
1). First , i will join these two variables value & store it in variable x.
Now the value of x is 25.
2). Now, we will minus the value of y(15) from this x(25).
we will get 10 & will store in variable y
3). Now the value on y is 10 & value of x is 25.
again we will minus this y value from & store it in variable x so value of variable of x will become 15.

Congratulation You have swapped the value of two variable without using third variable. :)





Tags :

Swap two variable without using third variable in Java

how two swap two variable in java without using third variable