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
- "Jenkins pipeline (pipeline) of combat: from deployment to experience" ;
- "Let Jenkins execution pipeline scripts on GitHub" ;
- "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:
- Deployment Jenkins;
- Experience pipeline;
Environmental Information
In order to quickly deploy Jenkins, this practical uses Docker, please have the following environment before the actual combat:
- Operating System: Ubuntu 18.04.2 LT
- Docker:19.03.1
Jenkins used this version is 2.176.3 .
Jenkins deployment
- Log in as root Linux, create a new folder, for example, I have here is / root / BlueOcean , enter this folder;
- 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:
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:
: 7. Jenkins has started installing plug-ins, as shown below, require you to wait a little
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:
9. click the bottom right corner of the "save and finish":
10. So far Jenkins environment has been deployed, view a list of installed plug-ins, discovery pipeline and blueocean have been installed:
Experience pipeline
Environmental ready, let's create a pipeline and try to run:
- As shown below, click on the red box "New Item":
- Fill in the form on page task name, and then select the "assembly line", as shown below:
- 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:
the red box 3 source code is as follows:
pipeline {
agent any
stages {
stage('Stage 1') {
steps {
echo 'Hello world!'
}
}
}
}
- Click below the red box "Build Now", you can execute the script just entered the pipeline:
- 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:
- The following figure, the console prints the information pipeline:
At this point, Jenkins environment has been ready, the next will experience the more practical function pipeline.