1 / 51

Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevOps Training | Edureka

** DevOps Training: https://www.edureka.co/devops ** <br>This Edureka tutorial on "Jenkins pipeline Tutorial" will help you understand the basic concepts of a Jenkins pipeline. Below are the topics covered in the tutorial: <br><br>1. The need for Continuous Delivery <br>2. What is Continuous Delivery? <br>3. Features before the Jenkins Pipeline <br>4. What is a Jenkins Pipeline? <br>5. What is a Jenkinsfile? <br>6. Pipeline Concepts <br>7. Hands-On <br><br>Check our complete DevOps playlist here (includes all the videos mentioned in the video): http://goo.gl/O2vo13

EdurekaIN
Télécharger la présentation

Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevOps Training | Edureka

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. What Will I Learn Today? Create your first Jenkins Pipeline Before Jenkins Pipeline Scripted Pipeline Demo What is Continuous Delivery? Declarative Pipeline Demo Why Continuous Delivery? What is a Jenkins pipeline? Pipeline Concepts DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  2. Why Do We Need Continuous Delivery (CD)? Developers Application directly deployed to prod Why did it fail? FAILURE POSSIBLE REASONS • Different environments (servers) • Different libraries & packages (dependencies) • End user load (traffic) • App not accessible to intended audience Manual testing (UT, IT) Code repo DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  3. CD Pipeline COMMIT (Version control system (Git)) BUILD CI-Jenkins (UT, IT) TEST ENVIRONMENT (Acceptance testing, Load testing) Developers Production ready DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  4. Advantages of Continuous Delivery Increases developer productivity Locates and addresses bugs quicker Automates software release DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  5. What is CD? • Continuous Delivery is a practise to continuously (any-time) release software • Code changes are continuously built, tested & pushed to a non- production environment by using automation tools • Software delivery cycles are more rapid and effective DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  6. uh CASE STUDY:- Continuous Delivery @ HP DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  7. HP Future Smart Case Study HP’s LaserJet firmware division builds firmware that runs all their scanners and printers Problems • In 2008, they were facing problems, their product delivery cycle was slow • It took them 6-12 months to build new features; making them slower than all their competitors DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  8. HP Future Smart Case Study Single platform to support the whole workflow Solution Improved quality releases Faster releases DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  9. HP Future Smart Case Study How did they achieve this? They implemented a CD pipeline with two key features • Practice CI • Automation at every step • Overall development cost reduced ~ 40% • Programs under development increased ~ 140% • Development cost per program went down ~ 78% DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  10. Before Jenkins Pipeline DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  11. Before Jenkins Pipeline Over the years, there have been multiple Jenkins pipeline releases including, Jenkins Build flow, Jenkins Build Pipeline plugin, Jenkins Workflow, etc. What are the key features of these plugins? Represent multiple Jenkins jobs as one pipeline What do these pipelines do? These pipelines are a collection of Jenkins jobs which trigger each other in a specified sequence DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  12. Build Plugin Pipeline Example • 3 jobs: Job1 → → building, Job2 → → testing the application and Job3 → → deployment • Chain these jobs together & run using Build Pipeline Plugin (better for small deployment) DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  13. Limitations Of The Build Pipeline Plugin Complex pipelines are hard to implement The maintenance cost is huge and increases with the number of processes Tedious to build and manage such a vast number of jobs DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  14. Jenkins Pipeline DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  15. What Is A Jenkins Pipeline? • Jenkins pipeline is a single platform that runs the entire pipeline as code • All the standard jobs defined by Jenkins are manually written in one script and they can be stored in a VCS • Instead of building several jobs for each phase, you can now code the entire workflow and put it in a Jenkinsfile DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  16. Key Features Of Jenkins Pipeline Incorporates user input Code can be checked into a VCS Restart from saved checkpoint Pipeline as code Allows conditional loops (for, when) Run jobs in parallel Integrate with other plugins DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  17. What is a Jenkinsfile? DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  18. What Is A Jenkinsfile? A text file that stores the pipeline as code It can be checked into a SCM on your local system Enables the developers to access, edit and check the code at all times It is written using the Groovy DSL Written based on two syntaxes DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  19. Two Ways Of Writing Jenkinsfile DECLARATIVE PIPELINE SCRIPTED PIPELINE • Recent feature • Simpler groovy syntax • Code is written locally in a file and is checked into a SCM • The code is defined within a ‘pipeline’ block • Traditional way of writing the code • Stricter groovy syntax • Code is written on the Jenkins UI instance • The code is defined within a ‘node’ block DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  20. Pipeline Concepts DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  21. Pipeline Concepts Pipeline: A user defined block which contains all the stages. It is a key part of declarative pipeline syntax. Note: Stages are explained in the following slides Node: A node is a machine that executes an entire workflow. It is a key part of the scripted pipeline syntax. DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  22. Pipeline Concepts Agent: instructs Jenkins to allocate an executor for the builds. It is defined for an entire pipeline or a specific stage. It has the following parameters: • Any: Runs pipeline/ stage on any available agent • None: applied at the root of the pipeline, it indicates that there is no global agent for the entire pipeline & each stage must specify its own agent • Label: Executes the pipeline/stage on the labelled agent. • Docker: Uses docker container as an execution environment for the pipeline or a specific stage. DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  23. Pipeline Concepts Stages: It contains all the work, each stage performs a specific task. Steps: steps are carried out in sequence to execute a stage DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  24. Create Your First Jenkins Pipeline DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  25. Create Your First Jenkins Pipeline Step 1: Log into Jenkins and select New Item from the Dashboard DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  26. Create Your First Jenkins Pipeline Step 2: Next, enter a name for your pipeline and select ‘Pipeline project’. Click ‘ok’ to proceed DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  27. Create Your First Jenkins Pipeline Step 3: Scroll down to the pipeline and choose if you want a Declarative or Scripted pipeline. DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  28. Create Your First Jenkins Pipeline Step 4a: If you want a Scripted pipeline, then choose ‘pipeline script’ and start typing your code DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  29. Create Your First Jenkins Pipeline Step 4b: If you want a Declarative Pipeline, select ‘Pipeline script from SCM’ and choose your SCM. In my case I’m going to use Git throughout this demo. Enter your repository URL DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  30. Create Your First Jenkins Pipeline Step 5: Within the Script path is the name of the Jenkinsfile that is going to be accessed from your SCM (Git) to run. Finally click on ‘apply’ and ‘save’. You have successfully created your first pipeline DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  31. Declarative Pipeline demo DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  32. Declarative Pipeline Demo (Code) Note: The code is explained in the following slides DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  33. Declarative Pipeline Demo (Code) Note: The code is explained in the following slides DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  34. Declarative Pipeline Demo Stage 1 runs a simple echo command Stage 2 executes an input directive Stage 3 runs ‘when’ directive with ‘not’ tag Stage 4 runs a parallel directive DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  35. Declarative Pipeline Demo Stage One The echo command specified in ‘steps’ block, displays the message runs a simple echo command Stage Two executes an input directive Stage Three runs ‘when’ directive with ‘not’ tag Stage Four runs a parallel directive DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  36. Declarative Pipeline Demo Stage One runs a simple echo command • Input directive allows to prompt a user input in a stage Stage Two executes an input directive • On receiving the user input the pipeline either proceeds with further execution or aborts Stage Three runs ‘when’ directive with ‘not’ tag Stage Four runs a parallel directive DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  37. Declarative Pipeline Demo Stage One runs a simple echo command Stage Two • ‘when’ executes a step depending on the conditions defined within loop executes an input directive • If conditions are met, corresponding stage is executed Stage Three • In this demo we’re using a ‘not’ tag runs ‘when’ directive with ‘not’ tag • This tag executes a stage when the nested condition is false Stage Four runs a parallel directive DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  38. Declarative Pipeline Demo Stage One runs a simple echo command Stage Two • Runs ‘Unit test’ and ‘Integration test’ stages in parallel executes an input directive • ‘Unit Test’ runs an echo command Stage Three • In ‘Integration test’ stage, a docker agent pulls an ‘ubuntu’ image & runs the reuseNode which is a Boolean (returns false by default) runs ‘when’ directive with ‘not’ tag • If true, the docker container will run on the agent specified at the top-level of the pipeline Stage Four runs a parallel directive DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  39. Declarative Pipeline Demo Now that I’ve explained the code, lets run the pipeline. The following screenshot is the result of the pipeline. In the below image, the pipeline waits for the user input and on clicking ‘proceed’ the execution resumes. DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  40. Declarative Pipeline Demo Final output of the Declarative pipeline demo DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  41. Scripted Pipeline Demo DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  42. Scripted Pipeline Demo (Code) To give you a basic understanding of the scripted pipeline, lets execute a simple code. I will run the following script DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  43. Scripted Pipeline Demo (Code) • The node block runs the conditional ‘for’ loop for creating 2 stages: Stage #0 & Stage #1 • These stages print ‘hello world!’ message • ‘if’ loop is used to execute 2 commands when ‘i’ = 0: ‘git’ command to clone the git directory & ‘echo‘ to display a message • ‘else’ is executed when ‘i’ != 0: ‘build’ executes the job (‘Declarative pipeline’) and then runs the echo command DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  44. Scripted Pipeline Demo Now that I’ve explained the code, lets run the pipeline. The following screenshot is the result of Stage #0. DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  45. Scripted Pipeline Demo Shows the logs of Stage #1 and starts building the ‘Declarative pipeline’ DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  46. Scripted Pipeline Demo Execution of the ‘Declarative pipeline’ DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  47. Scripted Pipeline Demo Results show the completion of ‘Declarative pipeline’ and Stage #1 DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  48. Summary Why Continuous Delivery? HP Future Smart Case Study What Continuous Delivery? What is a Jenkins Pipeline? What is a Jenkinsfile? Pipeline Concepts DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

  49. WebDriver vs. IDE vs. RC ➢ Data Warehouse is like a relational database designed for analytical needs. ➢ It functions on the basis of OLAP (Online Analytical Processing). ➢ It is a central location where consolidated data from multiple locations (databases) are stored. DEVOPS CERTIFICATION TRAINING www.edureka.co/devops

More Related