1. Introduction of
CI , CD, Jenkins CI: Continuous integration (Continuous integration, referred to as CI), in the traditional software development environment, there is integration, but there is no such thing as continuous integration, a long time branch and the main branch, resulting in branch There may be large deviations from the backbone, and it may take hours or longer to fix the code when integrating the code, so as to finally integrate the code into the backbone (commonly known as "integration hell" or "integration disaster"); CI aims to encourage Team members perform frequent integrations (for example, hourly or at least once a day) to avoid this situation. Through the process of automatic detection, pull, build and (in most cases) unit testing, the quality of the code can be guaranteed. For the next use, this is also the purpose of continuous integration. CI is an automated process belonging to developers.
CD: Continuous Delivery (Continuous Delivery) and Continuous Deployment (Continuous Deployment), here are some information and a brief summary:
1. Continuous delivery means that all changes can be delivered to production at any time, emphasizing that The ability to deliver
2. Continuous deployment means that all discovered release candidates and changes that pass all quality tests will be automatically deployed to the production environment, emphasizing one way
Jenkins: Jenkins is the leader of open source CI&CD software, and has many plug-ins to support it for continuous and automatic building/testing of software projects and monitoring the operation of external tasks
2. Install Jenkins on docker and
choose the image file of jenkins. It is recommended to use jenkinsci/blueocean. The image contains the current long-term support (LTS) version of Jenkins (which can be put into use) and bundles all Blue Ocean plug-ins and functions. This means that you do not need to install the Blue Ocean plug-in separately, the mirror address: https://hub.docker.com/r/jenkinsci/blueocean/copy the
code
docker run
-u root
–rm
-d
-p 8083:8080
-p 50000 : 50000
-v / Data / Jenkins: / var / jenkins_home
-v /var/run/docker.sock:/var/run/docker.sock
jenkinsci / BlueOcean
copy the code
parameters:
Automatically delete the Docker container when -rm is closed (the figure below is an example). If you need to exit Jenkins, this can be kept tidy;
-d Run the container in the background;
-p Map the 8080 port of the container service to 8090 of the host machine (my 8080 is already occupied by Apollo, so change it to 8083, you can No need to change, I found that many tools like to use port 8080, such as: Apollo, SkyWalking, and Jenkins here, etc.) port, the following is the same as 50000, map the port 50000 of the container to the port 50000 on the host;
-v here is Mount the local "/data/jenkins" directory to /var/jenkins_home in the container as the storage directory of jenkins; /var/run/docker.sock represents the Unix-based socket monitored by the Docker daemon word. This mapping allows the jenkinsci/blueocean container to communicate with the Docker daemon.
jenkinsci/blueocean is the image name
During docker run, if the image file does not exist, the image will be automatically pulled first, and then the container will be started. From the figure below, you can see a prompt stating that the image does not exist locally, and then the process of automatically pulling
After the installation is complete, open the browser to visit: http://deployed machine ip:8083 (default 8080 if it is not changed), you can see the Jenkins interface
Then use the following command to access the Jenkins console log and copy the password (between the two sets of asterisks is the generated administrator password) as
shown in docker logs
After copying the password, follow the prompts on the page, paste it, and click Continue to enter the next step
Click here to install the recommended plug-in, and then wait for the installation to complete
After the plug-in is installed, you can create a user according to the prompts or continue to use admin, and then click Save and Finish by default, and you can enter the Jenkins homepage.
At this point, the Jenkins deployment process is over, and then share two commands that may be used:
1. Visit Jenkins / Blue Ocean Docker container
docker exec -it bash
2. Visit Jenkins console log
docker logs
This command is used to obtain the administrator password. The deployment is quite fast. Let's try it!