Jenkins pipeline (pipeline) of combat: Experience from the deployment to

About Jenkins pipeline (pipeline)

Jenkins pipeline (pipeline) is a set of plug-ins, allowing Jenkins landing can be achieved and implemented continuous delivery pipeline.

About blueocean

Blue Ocean is a visual UI pipeline, the paper in the demo temporarily do not have access blueocean, follow-up article will be used;

Series of articles Address

  1. "Jenkins pipeline (pipeline) of combat: from deployment to experience" ;
  2. "Let Jenkins execution pipeline scripts on GitHub" ;
  3. "Jenkins made the GitHub project Docker image" ;

Benpian combat Overview

This article is "Jenkins pipeline (pipeline) combat" the first in a series, this content is deployed combat environment with a pipeline Jenkins plugin, then create and execute pipeline tasks, full text consists of the following components:

  1. Deployment Jenkins;
  2. Experience pipeline;

Environmental Information

In order to quickly deploy Jenkins, this practical uses Docker, please have the following environment before the actual combat:

  1. Operating System: Ubuntu 18.04.2 LT
  2. Docker:19.03.1

Jenkins used this version is 2.176.3 .

Jenkins deployment

  1. Log in as root Linux, create a new folder, for example, I have here is / root / BlueOcean , enter this folder;
  2. Execute the following command to create a good environment Jenkins:
docker run \
  -u root \
  -idt \
  --name blueocean \
  -p 8080:8080 \
  -p 50000:50000 \
  -v jenkins-data:/var/jenkins_home \
  -v /var/run/docker.sock:/var/run/docker.sock \
  jenkinsci/blueocean:1.19.0

The above command parameters, there are several things to note:
. A mirror is jenkinsci / BlueOcean: 1.19.0 : This is the official open source Jenkins mirror (https://github.com/jenkinsci/blueocean-plugin), which has been integrated pipeline and BlueOcean, very convenient;
B. -v-Jenkins Data: / var / jenkins_home : Jenkins container at work, if a command to be executed Docker (e.g. docker ps, docker run, etc.), needed a way to be connected to the sink host docker service, this parameter is used to establish a connection to the host docker container and services, if you want to learn more about this, please refer to the "docker's /var/run/docker.sock parameters" ;
. c -v /var/run/docker.sock:/var/run/docker.sock : the data container remains in the directory of the host, so even if the container collapsed, configuration and tasks which will not be lost;

3. Run Exec BlueOcean CAT Docker / var / jenkins_home / Secrets / initialAdminPassword , Jenkins container for acquiring log token, as shown, the console log output token is a60f9aa5ebd4400e92886ca49d574198 :

root@hedy:~# docker exec blueocean cat /var/jenkins_home/secrets/initialAdminPassword
a60f9aa5ebd4400e92886ca49d574198

4. Access browser: HTTP: //192.168.50.75: 8080, 192.168.50.75 is the IP address of the host, the page as shown below, fill in the login token just get in the red box a60f9aa5ebd4400e92886ca49d574198 , then click the lower right corner " continue "button:

Here Insert Picture Description
6. The next page is to allow the user to select which plug-in installation, as shown below, click on the red box inside, the official recommended to install plug-ins:
Here Insert Picture Description
: 7. Jenkins has started installing plug-ins, as shown below, require you to wait a little
Here Insert Picture Description
after 8 the plugin is installed will be asked to set up an account and password, set up after the lower right corner click "save and finish" button:
Here Insert Picture Description
9. click the bottom right corner of the "save and finish":
Here Insert Picture Description
10. So far Jenkins environment has been deployed, view a list of installed plug-ins, discovery pipeline and blueocean have been installed:
Here Insert Picture Description

Experience pipeline

Environmental ready, let's create a pipeline and try to run:

  1. As shown below, click on the red box "New Item":
    Here Insert Picture Description
  2. Fill in the form on page task name, and then select the "assembly line", as shown below:
    Here Insert Picture Description
  3. The next set of detailed form will pop up, as shown below, select the "pipeline" Tab page, enter a pipeline content directly on the page, then click on the lower left corner of the "Save" button:
    Here Insert Picture Description
    the red box 3 source code is as follows:
pipeline {
    agent any 
    stages {
        stage('Stage 1') {
            steps {
                echo 'Hello world!' 
            }
        }
    }
}
  1. Click below the red box "Build Now", you can execute the script just entered the pipeline:
    Here Insert Picture Description
  2. After the completion of the task execution as shown below, click on the red box icon to view the console output of this process task execution:
    Here Insert Picture Description
  3. The following figure, the console prints the information pipeline:
    Here Insert Picture Description
    At this point, Jenkins environment has been ready, the next will experience the more practical function pipeline.
Published 328 original articles · won praise 946 · Views 1.17 million +

Guess you like

Origin blog.csdn.net/boling_cavalry/article/details/100848333