Thursday, July 9, 2020

Jenkins Git Integration

Jenkins Git Integration Jenkins Git Integration Useful for Every DevOps Professional Back Home Categories Online Courses Mock Interviews Webinars NEW Community Write for Us Categories Artificial Intelligence AI vs Machine Learning vs Deep LearningMachine Learning AlgorithmsArtificial Intelligence TutorialWhat is Deep LearningDeep Learning TutorialInstall TensorFlowDeep Learning with PythonBackpropagationTensorFlow TutorialConvolutional Neural Network TutorialVIEW ALL BI and Visualization What is TableauTableau TutorialTableau Interview QuestionsWhat is InformaticaInformatica Interview QuestionsPower BI TutorialPower BI Interview QuestionsOLTP vs OLAPQlikView TutorialAdvanced Excel Formulas TutorialVIEW ALL Big Data What is HadoopHadoop ArchitectureHadoop TutorialHadoop Interview QuestionsHadoop EcosystemData Science vs Big Data vs Data AnalyticsWhat is Big DataMapReduce TutorialPig TutorialSpark TutorialSpark Interview QuestionsBig Data TutorialHive TutorialVIEW ALL Blockchain Blockchain TutorialWhat is BlockchainHyperledger FabricWhat Is EthereumEthereum TutorialB lockchain ApplicationsSolidity TutorialBlockchain ProgrammingHow Blockchain WorksVIEW ALL Cloud Computing What is AWSAWS TutorialAWS CertificationAzure Interview QuestionsAzure TutorialWhat Is Cloud ComputingWhat Is SalesforceIoT TutorialSalesforce TutorialSalesforce Interview QuestionsVIEW ALL Cyber Security Cloud SecurityWhat is CryptographyNmap TutorialSQL Injection AttacksHow To Install Kali LinuxHow to become an Ethical Hacker?Footprinting in Ethical HackingNetwork Scanning for Ethical HackingARP SpoofingApplication SecurityVIEW ALL Data Science Python Pandas TutorialWhat is Machine LearningMachine Learning TutorialMachine Learning ProjectsMachine Learning Interview QuestionsWhat Is Data ScienceSAS TutorialR TutorialData Science ProjectsHow to become a data scientistData Science Interview QuestionsData Scientist SalaryVIEW ALL Data Warehousing and ETL What is Data WarehouseDimension Table in Data WarehousingData Warehousing Interview QuestionsData warehouse architectureTalend T utorialTalend ETL ToolTalend Interview QuestionsFact Table and its TypesInformatica TransformationsInformatica TutorialVIEW ALL Databases What is MySQLMySQL Data TypesSQL JoinsSQL Data TypesWhat is MongoDBMongoDB Interview QuestionsMySQL TutorialSQL Interview QuestionsSQL CommandsMySQL Interview QuestionsVIEW ALL DevOps What is DevOpsDevOps vs AgileDevOps ToolsDevOps TutorialHow To Become A DevOps EngineerDevOps Interview QuestionsWhat Is DockerDocker TutorialDocker Interview QuestionsWhat Is ChefWhat Is KubernetesKubernetes TutorialVIEW ALL Front End Web Development What is JavaScript รข€" All You Need To Know About JavaScriptJavaScript TutorialJavaScript Interview QuestionsJavaScript FrameworksAngular TutorialAngular Interview QuestionsWhat is REST API?React TutorialReact vs AngularjQuery TutorialNode TutorialReact Interview QuestionsVIEW ALL Mobile Development Android TutorialAndroid Interview QuestionsAndroid ArchitectureAndroid SQLite DatabaseProgramming Development, Testing D eployment Technologies Involved In DevOps Git Useful for Every DevOps Professional Published on Dec 12,2019 315 Views Arvind Bookmark Become a Certified Professional DevOps is certainly incomplete without Jenkins. Jenkins along with Git is a wonderful combination. So in this article, I will talk about Jenkins Git Integration and its advantages. The pointers that we are going to cover are as follows:What is Git?What is Jenkins?Why Jenkins and Git are used together?Demo.So let us begin with our first topic.What is Git Why GitCame Into Existence?We all know Necessity is the mother of all inventions. Similarly, Git emerged to fulfill certain necessities that the developers faced before Git. So, let us take a step back to learn all about Version Control Systems (VCS) and how Git came into existence.Version Control is the management of changes to documents, computer programs, large websites and other collection of information.There are two types of VCS:Centralized Version Control System (CVCS)Distributed Version Control System (DVCS)Centralized VCSA centralized version control system (CVCS) uses a central server to store all files and enables team collaboration. It works on a single repository to which users can directly access a central server.Please refer to thediagram below to get a better idea of CVCS:The repository in the above diagram indicates a central server that could be local or remote which is directly connected to each of the programmers workstations.Every programmer can extract orupdate their workstations with the data present in the repository. They can also make changes to the data or commit to the repository. Every operation is performed directly on the repository.Even though it seems pretty convenient to maintain a single repository, it has some major drawbacks. Some of them are:It is not locally available; meaning you always need to be connected to a network to perform any action.Since everything is centralized, in any case of the central server getting crashed or corrupted will result in losing the entire data of the project.This is where Distributed VCS solves the problem.Distributed VCSThese systems do not necessarily rely on a central server to store all the versions of a project file. In Distributed VCS, every contributor has a local copy or clone of the main repository. Here everyone maintains a local repository of their own which contains all the files and metadata present in the main repository.You will understand it better by referring to the diagram below:As you can see in the above diagram, every programmer maintains a local repository on its own, which is actually the copy or clone of the central repository on their hard drive. They can commit and update their local repository without any interference.They can update their local repositories with new data from the central server by an operation called pull and affect changes to the main repository by an operation called push from their local repository.N ow let us try to know about the definition of Git.Git is a distributed version control tool that supports distributed non-linear workflows by providing data assurance for developing quality software. Tools like Git enable communication between the development and the operations team.Normally when you are developing a large project you have a huge number of collaborators. So it is very important to have communication between the collaborators while making changes in the project.Commit messages in Git play a very important role in communicating among the team. Apart from communication, the most important reason to use Git is that you always have a stable version of the code with you.Hence, Git plays a vital role in succeeding at DevOps.What is Jenkins?Jenkins is an open-source automation tool written in Java with plugins built for Continuous Integration purposes. Jenkins is used to build and test your software projects continuously making it easier for developers to integrate changes to the project, and making it easier for users to obtain a fresh build. It also allows you to continuously deliver your software by integrating with a large number of testing and deployment technologies.With Jenkins, organizations can accelerate the software development process through automation. Jenkins integratesdevelopment life-cycle processes of all kinds, including build, document, test, package, stage, deploy, static analysis and much more.Jenkins achieves Continuous Integration with the help of plugins. Plugins allow the integration of Various DevOps stages. If you want to integrate a particular tool, you need to install the plugins for that tool. For example Git, Maven 2 project, Amazon EC2, HTML publisher, etc.Advantages of Jenkins include:It is an open-source tool with great community support.Too easy to install.It has 1000+ plugins to ease your work. If a plugin does not exist, you can code it and share it with the community.It is free of cost.It is built with Java and h ence, it is portable to all the major platforms.You now know how Jenkins overcomes the traditional SDLC shortcomings. The table below shows the comparison between Before and After Jenkins. Before Jenkins After JenkinsThe entire source code was built and then tested. Locating and fixing bugs in the event of build and test failure was difficult and time-consuming, which in turn slows the software delivery process.Every commit made in the source code is built and tested. So, instead of checking the entire source code developers only need to focus on a particular commit. This leads to frequent new software releases.Developers have to wait for test resultsDevelopers know the test result of every commit made in the source code on the run.The whole process is manualYou only need to commit changes to the source code and Jenkins will automate the rest of the process for you.Why Jenkins and Git are used together?As discussed earlier, Git is a source control manager. That is where you keep you r source code for tracking all the code changes that happen over time and to baseline the versions when they are ready for release.Jenkins, on the other hand, is a continuous integration solution. It is devised to automate most of the tasks that a developer has to do while developing a new application (code quality checks, building, archiving of build artifacts, integration testing, deployment to various environments, etc.) Without a CI solution, a developer has to spend much time doing these repetitive non-productive tasks.Advantages:Git and Jenkins are both very powerful, but with great power comes great responsibility. Its pretty common to justify an unnecessary amount of complication in a build pipeline simply because you can.While Jenkins has a lot of neat tricks up his sleeve, it is easy to leverage the features of Git, as it makes release management and bug tracking significantly easier over time.We can do this by being careful about the versions of code that we build and tag ging them appropriately. This keeps release-related information close to the code, as opposed to relying on Jenkins build numbers or other monikers.Protecting Git branches reduces the risk of human error, and automating as many tasks as possible reduces how often we have to pester (or wait on) those humans.Example:Let us take the example of a new feature in a web application. A developer will be identified and assigned to the task, he takes the existing codebase from the Source control say, Git, makes his changes, carries out unit testing, ensures code quality manually and checks the new code back into Git. Then he has to build the code, deploy it into integration instance, run integration testing and once the change seems satisfactory, raise a request for production deployment. Now, if only we had a minion to take care of this testing, building, quality checks and deployment sections the poor developer could have focused better on that stuff he is really good at implementing and improving the features logic.This minion is Jenkins. It acts as an orchestrator to run all these activities once the change is checked into source control (Git) and thus gives quick feedback to the developer whether the changes he has made are good enough for production deployment or not. It is an extremely flexible, open-source and has a ton of plugins that can do almost anything you wish it to do. DemoHere we will see how to integrate Git with Jenkins. There are 5 steps that you must follow :1. Create a Sample program: You can create any sample program that you want like Java or Python or any other program. Here we will write a simple Python program that prints Hello, World!2. Create a Jenkins job:Here first you need to start Jenkins using the command prompt.For that, you first need to navigate to the Jenkins location on your system and use the command java -jar jenkins.warAfter running this command, open the web browser and go to Jenkinss home page using the link localhost:8080. This is the default port number.Open Jenkins home page by entering the username and password.For creating a project click on New Item and enter the project name and select Freestyle project. Click on OK.3. Add this program to Github:Open git bash on your system. Navigate to the location of your program. Initialize an empty repository using the command git init.Use the command git add . to add the file to the staging area from the working directory.Now add the file to the local repository using the command git commit -m demo.py file added.Now you have to push this file to the remote repository. For doing that go to your GitHub account and create a new public repository. Now copy the location of this repository and go to git bash terminal. Here type the command git remote add origin location-of-repository. Since now you have connected to the remote repository, you can now push your code there using the command git push -u origin master. To verify this go to GitHub account and refresh the page. You will see the file added there.4. Add Git Plugin in Jenkins:On Jenkinss homepage go to Manage Jenkins.Next click on Manage Plugins. Here check got Git plugin in the installed section. If it is not available here search for it in the available section and download it.5. Configure Jenkins job to trigger the build:Go to the project in Jenkins that we created in step 2. Here in the Source Code Management section, select git and enter the link of the public repository that you created in step 3. Next in the Build Triggers section, click on Poll SCM option. Here in the Schedule part, you have to enter five asterisks separated by space. This is nothing but cron syntax for your job. This means that Jenkins will check for any changes in the source code every minute and if there is any change it will trigger the Jenkins build.Click on Apply and then on Save. Next on your project home page click on Build Now. This will run the project and in the console output, you can see your pr ogram output the status of your Jenkins job. If everything is alright then it will display as Success.So this how Jenkins Git Integration is done. With this, we have come to the end of this article on Jenkins Git Integration. I hope you have enjoyed this article.Now that you have understood what Jenkins Git Integration is, check out thisDevOps trainingby Edureka,a trusted online learning companywith a network of more than250,000satisfied learnersspread acrossthe globe. The Edureka DevOps Certification Training coursehelps learners to understand what is DevOps and gain expertise in various DevOps processes and tools such asPuppet, Jenkins, Nagios, Ansible, Chef, Saltstack and GIT for automating multiple steps in SDLC.Got a question for us? Please mention it in the comments section and we will get back to youRecommended videos for you What is Jenkins? Continuous Integration With Jenkins Watch Now Ansible Tutorial For Beginners Ansible Playbook Watch Now DevOps is Going to Replace SDL C! Learn Why Watch Now DevOps-Redefining your IT Strategy Watch Now What is DevOps A Beginners Guide To DevOps Watch Now Top DevOps Interview Questions And Answers Watch Now What is Docker DevOps Tool For Containerization Watch Now Continuous Integration With Jenkins Watch Now Puppet Tutorial DevOps Tool For Configuration Management Watch Now Devops : Automate Your Infrastructure With Puppet Watch Now What is Git A Complete Git Tutorial For Beginners Watch Now 5 Best Practices In DevOps Culture Watch Now DevOps Tutorial For Beginners Watch NowRecommended blogs for you Linux commands in DevOps: Must Know For Every DevOps Professional Read Article Install Chef 6 Simple Steps for Installing Chef On CentOS Read Article All You Need To Know About DevOps Read Article Git bisect: How to identify a bug in your code? Read Article How To Use GitHub Developers Collaboration Using GitHub Read Article Setting Up Development Environment Using Vagrant Read Article Docker Compose For Containe rizing A MEAN Stack Application Read Article What Is Chef? A Tool Used For Configuration Management Read Article DevOps Real Time Scenarios Know What Happens Real Time Read Article How To Configure Email Notification In Jenkins In 6 Simple Steps? Read Article Docker For Windows | Setting Up Docker On Windows Read Article Install Git Git Installation On Windows And CentOS Read Article DevOps Tutorial : Introduction To DevOps Read Article Docker Networking Explore How Containers Communicate With Each Other Read Article Kubernetes Tutorial A Comprehensive Guide For Kubernetes Read Article Secure Your Secrets With Ansible Vault Read Article What Is Git ? Explore A Distributed Version Control Tool Read Article DevOps Life cycle: Everything You Need To Know About DevOps Life cycle Phases Read Article Top 50 Kubernetes Interview Questions You Must Prepare In 2020 Read Article Gitting Ahead: Hacking Git and GitHub Part 2 Read Article Comments 0 Comments Trending Courses in DevOps D evOps Certification Training72k Enrolled LearnersWeekend/WeekdayLive Class Reviews 5 (28750)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.