Skip to content

Commit 29e0a8d

Browse files
committed
Added new video
1 parent 1432e6c commit 29e0a8d

File tree

3 files changed

+121
-0
lines changed

3 files changed

+121
-0
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
layout: post
3+
title: "CCJPE: Pipeline Plugin"
4+
date: 2016-7-16 12:00:00 -0500
5+
categories: Jenkins
6+
permalink: lessons/ccjpe-pipeline
7+
excerpt: "Learn how to set up Jenkins Pipeline-as-Code"
8+
weight: 9
9+
image: 'jenkinscourse.png'
10+
11+
---
12+
{% include youtube.html id="BE3nTW-h4E0" %}
13+
14+
Introduction
15+
------------
16+
Welcome to the DevOps Library! This is Samantha, and in this episode, we're
17+
going to take a look at the [Jenkins Pipeline plugin](https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Plugin). A Jenkins pipeline allows
18+
you to define an entire application life cycle as code. In most cases, you'll
19+
want to use this plugin for implementing continuous delivery.
20+
21+
![Pipeline](/images/pipeline.png)
22+
23+
Benefits
24+
--------
25+
One huge benefit of using a pipeline is that the job itself is durable. A
26+
Pipeline job is able to survive planned or even unplanned restarts of the
27+
Jenkins master. If you need to survive slave failures as well, you’ll have to
28+
use checkpoints.
29+
30+
Unfortunately, the [checkpoints plugin](https://www.cloudbees.com/products/cloudbees-jenkins-platform/enterprise-edition/features/checkpoints-plugin) is only available for the enterprise
31+
edition of Jenkins. Pipelines are also pausable. You can use an "input" step
32+
to wait for human input or approval before continuing the job.
33+
34+
They're also versatile and extensible. You can set up pipelines that fork,
35+
join, loop, and even execute items in parallel. You can also use custom
36+
groovy to extend the Pipeline DSL.
37+
38+
Pipeline Vocabulary
39+
-------------------
40+
Alright, it's time to cover some pipeline vocabulary.
41+
Each pipeline generally consists of three things: Steps, Nodes, and Stages.
42+
43+
A step, also known as a "build step", is a single task that we want Jenkins to
44+
execute.
45+
46+
A “node”, within the contexts of a pipeline, refers to a step that does two
47+
things. First, it schedules the defined steps so that it'll run as soon as an
48+
executor is available. Second, it creates a temporary workspace which is
49+
removed once all steps have completed.
50+
51+
And lastly, we have "Stages". Stages are for setting up logical divisions
52+
within pipelines. The Jenkins Pipeline visualization plugin will display each
53+
stage as a separate segment. Because of this, teams tend to name stages for
54+
each phase of the development process, such as "Dev, Test, Stage, and
55+
Production".
56+
57+
Setting up a Pipeline
58+
---------------------
59+
Alright, let's go ahead and set up a Pipeline ourselves!
60+
On your Jenkins master, select "New Item". For the type, choose Pipeline, and
61+
name it whatever you'd like and hit ok. Now scroll down to the Pipeline
62+
definition. At this point, you can select "Pipeline script", or "Pipeline
63+
script from SCM".
64+
65+
While the pipeline is going to look the same either way, if you select
66+
"from SCM", Jenkins will look for a "Jenkinsfile" within your repository. The
67+
advantage of storing the script in a "Jenkinsfile" is that you'll be able to
68+
version control your "Pipeline as Code".
69+
70+
![Sample Jenkinsfile](/images/jenkinsfile.png)
71+
72+
For now, let's choose "Pipeline as Script", that way we don't have to worry
73+
about setting up a repository.
74+
75+
Alright, now onto the script itself. Let's go ahead and click the "try sample
76+
Pipeline" box. Next, choose "hello world". Perfect, that should be enough to
77+
get us started, but let's change the stages a bit. For the two listed, rename
78+
them to DEV, and QA, then add a third stage named "Production".
79+
80+
Snippet Generator
81+
-----------------
82+
I know we're only echoing out a few messages in this tutorial, but you can
83+
always use the snippet generator to help you write more complex pipelines.
84+
Let's take a quick look at it.
85+
86+
Under "Sample Step", click the drop down and look at all our options. Select
87+
"Build a job", type in the name of a project to build, and finally select
88+
"Generate Groovy".
89+
90+
See? Now we know exactly what we'd need to add if we wanted to include a build
91+
step.
92+
93+
Exam Tip
94+
--------------
95+
Here’s a quick tip for the CCJPE exam. You don’t need to worry about
96+
memorizing each snippet, but you do need to know the term "parallel". By
97+
placing steps within a "parallel" section, Jenkins will kick off each step at
98+
the same time. Otherwise, Jenkins will wait for each step to finish before
99+
starting the next one.
100+
101+
Alright, let's get go ahead and try out our pipeline. Save the job, then on the
102+
next page, click "Build Now" to start the Pipeline.
103+
104+
You may have to wait a minute or so for it to finish running, but check out how
105+
nice our pipeline looks! Great job!
106+
107+
Conclusion
108+
----------
109+
Well, that's it for our lesson on the Jenkins Pipeline Plugin. If you'd like to
110+
learn more, check out the documentation at [Jenkins.io](https://jenkins.io/doc/pipeline/). Another good place to
111+
look is on the CloudBees blog, we highly recommend reading the articles by
112+
[Hannah Inman](https://www.cloudbees.com/blog/using-pipeline-plugin-accelerate-continuous-delivery-part-1).
113+
114+
Thank you as always for watching! If you like our videos, please subscribe
115+
to our YouTube channel!
116+
117+
[Subscribe to our YouTube channel](https://www.youtube.com/channel/UCOnioSzUZS-ZqsRnf38V2nA?sub_confirmation=1) or follow [DevOpsLibrary on Twitter](https://twitter.com/intent/user?screen_name=devopslibrary).
118+
119+
{% include subscribe.html %}
120+
121+
Thank again and see you soon.

images/jenkinsfile.png

73.6 KB
Loading

images/pipeline.png

68.9 KB
Loading

0 commit comments

Comments
 (0)