White Paper Getting Started with Continuous Integration in Software
Total Page:16
File Type:pdf, Size:1020Kb
WHITE PAPER GETTING STARTED WITH CONTINUOUS INTEGRATION IN SOFTWARE DEVELOPMENT Amruta Kumbhar, Madhavi Shailaja & Ravi Shankar Anupindi Introduction DevOps culture is gaining rapid momentum in the IT industry as it enables business to adopt agile software delivery methodologies like Continuous Integration (henceforth referred to as CI) & Continuous Delivery (henceforth referred to as CD) .These methodologies enable quicker issue resolution, instant feedback loops, improved software quality and cost saving to meet the ever- increasing demand to deliver better software faster. It would not be wrong to say that CI-CD practices will soon become the de- facto software delivery standards across the industry. Though both these methodologies (CI and CD) This article compiles insights gained from complement each other, CI is the pre-requisite our practical experiences across various CI phase for enabling CD as the latter is built on enablement programs which we have been Gartner says “By 2016, top of the former. The primary goal of CI is associated with. not only to enable build automation through DevOps will evolve Some of these experiences might vary continuous test and quality checks but also to from a niche to a depending on the choice of tools, provide project insights through reports and infrastructure setup, organization policies mainstream strategy dashboards. Since this phase is all about tools, and project requirements. In spite of the employed by 25 it imposes various integration challenges. differences, we hope, this article will act as Having a good knowledge of the tools Percent of global 2000 a helping guide to all those planning for CI involved, their integration aspects and the organizations” setup in their projects. best practices to follow, will definitely enable their smoother adoption and rollout across This article is organized into different sections enterprises looking to adopt CI practices. as below – Section 1 Section 2 talks Section 3 Section 4 Section 5 Section 6 And we nally shows the CI about the discusses the includes some enumerates shows the summarize our setup which we various tools challenges of the best some of the deployment ndings in have been being used to faced and the practices that benets topology for Section 7. using. achieve CI. solution can be adopted obtained the CI setup approaches we for CI from CI used. External Document © 2018 Infosys Limited External Document © 2018 Infosys Limited 3 Build Source Control Server Continuous Integration Server 2 Fetch Changes Test 4 5 Failure or Success 6 Notify Success or Failure Check in Changes 1 Various stakeholders Developer 1 Developer 2 Continuous Integration Setup The below diagram illustrates the end to Integration server. Developers check-in notifications for any failure scenario end Continuous Integration (CI) setup the code into source control server which which enables the development team to which we have been following across is integrated with CI server. For each build, take immediate action. This continuous projects. As seen below, the main actors CI server is configured to run the JUnit test automation chain helps in reducing include the Development team, the Source cases, Selenium based functional test cases, the overall defect density and thereby Control Server and the Continuous code quality checks and provide improving the code quality. Tools Adoption recommended that every organization successfully across various projects for CI CI depends mostly on adopting the must do proper due diligence in evaluating enablement. As seen, we have adopted correct set of tools and their proper different toolsets and choosing the Jenkins as the continuous integration usage. The selection of tools is appropriate ones suitable for their platform but there are other CI platforms generally driven by various IT policies requirements. (Bamboo, TeamCity etc.) to choose from. in the organization, existing technology The same case holds good for other landscape, current infrastructure setup, The diagram below shows the toolsets toolsets also. and other considerations. It is therefore (phase wise) which we have been using Develop Build Test Deploy01 Continuous Integration • Open Source • Widely used in industry • Provides varied plugins Version Control Build Automation Code Quality Analysis Artifact Management • Open Source • Open Source • Integrated test cases • Widely used in industry • Widely used in industry • Widely used in industry • Code quality dashboard • Ease of conguration • Jenkins integration • Jenkins compatible • Jenkins integration • Jenkins integration External Document © 2018 Infosys Limited External Document © 2018 Infosys Limited Challenges Faced We faced a few challenges during our CI journey and some of the major challenges encountered are explained below. Providing Granular Level Access Regular Build Failures Builds Waiting for GIT Repository Integration In Jenkins Node Executor 1 2 3 4 Providing individual level access was Most common issue faced. Jobs were Due to node dependency, projects Issue while creating a trusted link a redundant and time consuming failing because of perm gen space were waiting in the queue even if between GIT and Jenkins server task issue. Memory consumption on slave idle executors were available on nodes was high due to Jenkins job other nodes. Builds were waiting for workspace and generated artifacts executor due to heavy build load Solution Approach Solution Approach Solution Approach Solution Approach We came up with the role based To solve this issue, cron scripts Even Scheduler plugin was used Trust was created between GIT access solution approach. This were created to clean up the job to ensure that load distribution and Jenkins using public and approach helped to provide workspace and artifacts once a was happening evenly across all private keys of Jenkins server access to roles rather than week, in order to release the nodes individual level memory External Document © 2018 Infosys Limited External Document © 2018 Infosys Limited Best Practices Followed Providing individual level access is always After having worked on multiple CI Role Based Access a cumbersome task and therefore it is recommended to provide Role-Based access enablement projects we have condensed together the set of best practices which Cron scripts were created to clean up the job workspace and artifacts once a week, in order we have learnt/followed. Most of these Regular cleanup of workspace & artifacts to ,release the memory and thereby avoid practices have been standardized and memory leak issues published as CI guidelines for internal usage Even distribution of To overcome the default behavior of Jenkins across teams. In this section we highlight workload across nodes in terms of node picking job, Even Scheduling some of the best practices which we follow plugin was used which ensuresd even ( Even Scheduler plugin) distribution of work load across nodes and would like to share with others. Template based centralization of common properties across projects Benefits Realized Following are some of the benefits which we have realized by CI enablement across projects. Build Automation Code Stability Analytics CD Enablement 100% 100% 100% 100% Builds were automated Notication feature Sonar dashboard Workow conguration by using the Poll SCM enabled development provided centralized view on Jenkins enabled auto feature of Jenkins. This team to respond quickly of code quality issues and deployment of not only enabled faster to the build failure dashboards created application artifacts builds but also helped scenarios. This helped in leveraging Jenkins APIs, (EAR/WAR les) on the to eliminate manual quicker resolution of code provided complete build required application build eort issues and ultimately led information. This enabled server whenever a new to stable code base project teams to take snapshot version of the timely corrective steps artifact was available Faster Releases Cost Savings Improved Productivity Improved Code Quality 50% CI enabled faster release Many projects cut down CI-enablement helped CI-enablement helped cycles with stable code on the cost to maintain increase development increase development 30% 30% separate build teams team productivity by 25% team productivity by after build automation. relieving them from relieving them from This resulted into build related aspects build related aspects signicant cost savings with complete focus on with complete focus on for them their core development their core development activities activities Note: The above mentioned quantitative improvements are the average % improvements which have been observed across various projects. External Document © 2018 Infosys Limited External Document © 2018 Infosys Limited Topology and Deployment view Below is the high-level topology of the Moreover, executing jobs on the master’s workload of building projects is delegated CI platform which we have been using. executors can introduce a security issue. to multiple slave nodes. The key benefits of this topology are high Any Jenkins’s user with full permissions If you notice we have enabled Jenkins availability and scalability. To achieve high can play havoc with the system as they will master to only handle HTTP requests and scalability and distributed build system we have direct access to private information manage the build environment. Actual have set up dedicated build nodes that run whose integrity and privacy could not be, execution of builds will be delegated to the separately from