Introduction to Git and Jenkins

Share on facebook
Share on twitter
Share on linkedin
Git is the distributed version control system. It allows us to have “versions” of a project and tracks the changes made to the code over the time.

 Introduction to Git 

Git is the distributed version control system. It allows us to have “versions” of a project and tracks the changes made to the code over the time. Also, we can compare two versions and undo the changes if necessary. Git plays a vital role on larger projects in which more than one developers are working on the same project.

For Further exploration, refer: https://git-scm.com/videos

Steps to Install Tortoise 

  1. Go to link https://tortoisegit.org/
  2. Click Download.
  3. Choose the download link that suits for your system (either for 32-bit OS or for 64-bit OS)
jenkins git

4.Once the download is completed, follow the below steps to Install tortoise:  ​

  1. Open Set up Wizard.
  2. Click Next [Symbol] Next [Symbol]Install.
  3. Select Yes to install.
  4. Click Finish.

 Steps to Create Account in GitHub 

  1. Go to the link https://github.com/
  2. Fill in the following fields: Username, Email Address and Password for the GitHub Account.
  3. Click Sign up for GitHub Button.
  4. Choose Unlimited public repositories for free as personal plan.
  5. Click Continue Button.
  6. Provide the general information, if necessary. Otherwise skip this step.
  7. Click Submit Button.

To Create a Repository in GitHub 

  1. Click the plus on the top right corner. Choose New Repository.
jenkins git
  1. Enter the name and Description (Optional) of the repository.
  2. Select Initialize this repository with a README.
  3. Click Create Repository Button.
jenkins git

Steps to Create Branch 

  1. Go to the Repository.
  2. Click the Branch: Master drop down.
  3. Give name for the Branch and Click Create Branch
jenkins git

To Clone the Git to local System 

  1. Go to the repository. Click Clone or Download Button
  2. Copy the URL from the drop down.
jenkins git
  1. Create a New Folder in your System.
  2. Right Click on the folder. Choose Git Clone.
jenkins git
  1. In the dialog box, paste the above copied URL in URL field.
jenkins git
  1. Click OK Button.

Command to clone Repository,

Git clone https://github.com/your-username/repository-name

e.g.: Git clone https://github.com/MetaSoftTechSys/TestProject

To Pull code from GitHub 

  1. Right Click on the folder (That is cloned in the above step)
  2. Choose TortoiseGit [Symbol] Pull [Symbol] Click Ok.
  3. To view the difference, Click Pulled Diff.
jenkins git
jenkins git

Command to pull: 

Git pull

To Commit code to GitHub 

  1. Place the code in the folder to which want to commit.
  2. Right Click on the root folder. Choose “Git Commit [Symbol] …”.
jenkins git
  1. Provide the Message for Commit.
  2. Select the files which you want to commit.
  3. Click Ok Button.

Command to Commit: 

Git Commit –all

To Push Code to GitHub

  1. Right click on the Folder. Choose TortoiseGit [Symbol] Push.
  2. Select the branch to which you want to push.
  3. Click Ok Button.
jenkins git
jenkins git

Command to Push: 

Git Push

To Change the Branch 

  1. Right Click on the Folder. Choose TortoiseGit [Symbol] “Switch/Checkout…”.
  2. Select the branch from the list.
  3. Click Ok.
jenkins git

Command to change branch: 

Git checkout branch-Name.

e.g.: Git checkout test-branch –1

Jenkins – Continuous Integration (IC)

1. Introduction 

Jenkins is a tool to perform continuous integration and build automation. We can trigger the execution based on time or event. For example, every 20 minutes or after a new commit in a Git repository. It can be integrated with several testing environments (Sandboxes)–which means whenever a new commit is made in Git repository, integration with several sandboxes can be initiated at the same time.

Workflow: 

Text Box
Text Box
Shape
Shape
jenkins git

Text Box    Commit the changes to Git.

Shape

Jenkins automatically kickoff

Shape
Shape

Changes deployed to multiple environments.

Text Box
Text Box

2. Code Delivery Process 

a) Develop and Commit changes to the Git.

Developers can develop and validate their code in the sandbox. Once the development is complete, the code shall be committed and pushed to Git. The below image shows the Code committed to GitHub.

jenkins git

b)  Jenkins validation. 

Whenever the codes are pushed to Git, Jenkins automatically starts validation to the Connected Environment (QA Sandbox, Full Copy Sandbox, etc.).

c)  Notification about the build success or failure.

If the ball near the job is red color, it indicates that the validation failed. The blue color indicates that the validation is success. The User is notified about error if the validation fails.

If the validation fails, we must fix the error and again commit the changes to Git.

jenkins git

d) Deploy Changes 

Once the validation is successful, deploy the changes to the environment manually.

To deploy Changes,

1.Click Deploy Job Name [Symbol] Build with Parameters and [Symbol] Build.

jenkins git

Conclusion: 

Using Jenkins, we can discover deployment issues earlier and automate build to multiple environment on each commit to the repository.

Reference Link 

About MST

At MST Solutions our cornerstone is to adapt, engage and create solutions which guarantee the success of our clients. The talent of our team and experiences in varied business verticals gives us an advantage over other competitors.

Recent Articles

Mobile Responsive Testing

Mobile Responsive Testing is simply a Testing Process performed to make sure that your website or an app is working appropriately on all types of devices.
Whether it an app or website, they need to ensure that they are accessible from any device, anytime, anywhere.

Read Article »

Work with us.

Our people aren’t just employees, they are key to the success of our business. We recognize the strengths of each individual and allow them time and resources to further develop those skills, crafting a culture of leaders who are passionate about where they are going within our organization.