CICD之jenkins

What is jenkins? Why use jenkins? How to install and use jenkins? This article mainly answers these questions.

what is jenkins

From the introduction on the official website ( https://jenkins.io/zh/ ): Jenkins is a leader in open source CI & CD software, providing more than 1,000 plug-ins to support construction, deployment, and automation to meet the needs of any project. CI & CD (Continous Integration & Continous Delivery) can greatly improve the application efficiency from the source code to the production environment by including automatic build, test, and deployment pipelines, especially for projects that require frequent changes. . Jenkins provides such a software service. So in the sense of use, jenkins is software for providing CI & CD services. Just like a housekeeper, jenkins does not necessarily provide any special functions. Its biggest advantage is that it is automatically executed at a suitable time (timing or event trigger) according to a pre-defined process, thereby reducing manual operations.

Why use jenkins

The application platform is wide, the configuration is simple, the plug-in is rich, the scalability is strong, and the distribution is supported.

First of all, from the platform of use, Jenkins contains windows, mac os x and linux operating systems to facilitate installation. In addition, Jenkins provides web page configuration, making configuration more convenient and simple. Jenkins provides more than 1,000 plug-ins, with powerful capabilities to complete the corresponding work (for example, the docker plug-in can perform the packaging, uploading and downloading of images). Jenkins can use plug-ins and other architectures, and it also provides rich interfaces (such as restapi interface and git interface). In addition, Jenkins can support distributed, distribute specific tasks to different machines for execution, improve the efficiency of compilation, testing and deployment.

How to install jenkins

For details, please refer to the official website https://jenkins.io/zh/doc/book/installing/ to install. Take the deepin (Linux debian improved version) operating system as an example here. The environment to be prepared is: jdk, docker

Jenkins is compiled with java, so jdk environment is required. The current jdk8 official website download ( https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html ) requires oracle registration to download. Unzip after downloading, and move the decompressed folder to a specific path (this step is not necessary, I generally put the file under the / opt / java / jdk path), modify / etc / profile, insert the following paragraph:

export JAVA_HOME= /opt/java/jdk
export JRE_HOME = /opt/java/jdk/jre
export JAVA_CLASS = $JAVA_HOME/lib
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin

Then execute source / etc / profile 

Use java -version to check whether the installation is successful.

Above you can see the successful installation of jdk.

docker installation:

This article https://www.cnblogs.com/jason1990/p/9887353.html describes the installation process.

After the above configuration environment, start to execute.

Note that this is installed through a binary file, there is no daemon.json file under / etc / docker, if you want to configure the local docker, you need to

/ etc / docker creates a daemon.json or specifies the configuration file by dockerd --confile = XXX. Then use systemctl reload-daemon to reload the configuration, use systemctl restart docker.service to restart the docker service, and check the status through systemctl status docker -l or docker info.

Use docker to run jenkins.

Execute the command to start jenkins: docker run -u root --rm -d -p 8080: 8080 -p 50000: 50000 -v jenkins-data: / var / jenkins_home -v /var/run/docker.sock:/var/ run / docker.sock jenkinsci / blueocean The mirror here, jenkinsci / blueocean, may not be available and cannot be obtained through the accelerator. You can download it through Alibaba Cloud.

After running locally, you can check that jenkins is being initialized through localhost: 8080. After a short wait, the system prompts you to enter the admin password ( https://jenkins.io/doc/book/system-administration/viewing-logs/ to view Password location). Since we use docker to run, we can directly view through docker logs containerid. After inputting, we can see the following interface after a period of time.

Then you can configure. If it is a domestic network, it is likely to fail to download the plug-in. At this time, you can download the Jenkins plug-in file manually, and then install the relevant plug-in through the offline method ( https://www.cnblogs.com/yy-cola/p/10162062.html ) http: //updates.jenkins-ci .org / download / plugins / . I wo n’t go into details here.

Then you can use the jenkins as a server to build.

 

Published 42 original articles · praised 4 · 10,000+ views

Guess you like

Origin blog.csdn.net/wangyhwyh753/article/details/105506032