Jenkins combat (a): Jenkins entry and installation

Here Insert Picture Description
Jenkins For developers, should not be unfamiliar. In software development, deployment phase, in order to achieve automation, we will be the preferred Jenkins build automation tools to complete, it is an integral part of the development. This series of "Jenkins combat" articles will in practical work, Jenkins is how to use, how to play its role, how to help us work more efficiently. This can be considered a work record summary of it to share with everyone.

First, what Jenkins is

Jenkins is an open source CI & CD software leader , providing over 1000 plug-in to support the build, deploy, automate , to meet the needs of any project. And it provides running very good user interface, mainly used for continuous, automated build / testing software projects, external monitoring tasks.

Usually with version management tool, build tool used in combination. Commonly used version control tools SVN, GIT, build tools Maven, Ant, Gradle.

Official website: https://jenkins.io

It has the following features:

  • Open-source continuous integration tool for java language development, support CI, CD;

  • Easy to install deployment configuration: by mounting yum, or war package download and installation docker containers quickly achieved through deployment, configuration management easy web interface;

  • And the test report message notification: Integrated RSS / E-mail released through RSS or build results when the build is complete notification by e-mail, generating JUnit / TestNG test report;

  • Distributed building: support for Jenkins to allow multiple computers to build / test together;

  • File identification: Jenkins can keep track of which generates a jar build what time, what time building such as the use which version of the jar;

  • Rich plug-ins support: supports extensions, you can develop your own tools for team use, such as git, svn, maven, docker and so on.

Second, what CI / CD is

When used or mentioned Jenkins, you will often hear CI, CD two terms, in this case, it is necessary to separate presentation to explain, for subsequent chapters mention is not confused.

1. CI (continuous integration)

CI (Continuous Integration), Chinese it is called continuous integration, is a let developers will be integrated into the work sharing process branches to enhance the development of writing.

After continuous integration emphasize developer submitted a new code, immediately build, test. According to test results, we can determine the new code and legacy code is properly integrated.

As shown in FIG procedure:
Here Insert Picture Description

2. CD (continuous delivery)

CD (Continuous Delivery), Chinese name for sustained delivery is in continuous integration on the basis of the code is deployed to integrate closer to real operating environment (such as: production-environment).

For example, after we complete the unit test, code can be deployed to connect the database Staging environment more tests. If the code is no problem, you can continue manual deployment to a production environment. The following figure probably reflects the mode of CI / CD's.
Here Insert Picture Description

Three, Jenkins installation

1. Preparations

The following is the official Jenkins recommends installing server software requirements.

  • Machine Requirements:
    • 256 MB RAM, 512 MB recommended greater than
    • 10 GB of hard disk space (Jenkins and Docker mirror)
  • You need to install the following software:
    • Java 8 (JRE or JDK can)
    • Docker

I will be ready here is on CentOS 7.5 environment, the use of non-docker way to install it.

2. Install JDK1.8

If you have installed, omit this step.

Execute the command yum install -y java-1.8.0to install:

[root@xcbeyond ~]# yum install -y java-1.8.0

3. Install Jenkins

1) perform wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repoto get jenkins.repo.

[root@xcbeyond ~]# wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
[root@xcbeyond ~]# rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

If the import had before jenkins key, the implementation rpm --importwill fail, can be ignored.

2) execute yum install jenkinscommand to install Jenkins. During the installation process will download some rpmpackages will be slow, please be patient installation is complete.

[root@xcbeyond ~]# yum install jenkins

3) execute systemctl start jenkinsthe command to start the Jenkins.

[root@xcbeyond ~]# systemctl start jenkins

4) execute ps aux | grep jenkinscommand to view the startup status of Jenkins, and some parameters at startup.

[root@xcbeyond ~]# ps aux | grep jenkins
jenkins    6212  208  2.4 5535708 197740 ?      Ssl  19:33   0:41 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --daemon --httpPort=8080 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20
root       6264  0.0  0.0 112720   980 pts/0    S+   19:33   0:00 grep --color=auto jenkins

Start by looking at the status of Jenkins, Jenkins can know the default installation directory (JENKINS_HOME) is located /var/lib/jenkins, the log is located/var/log/jenkins/jenkins.log

4. initialization, configuration Jenkins

Up to now, only completed the basic installation Jenkins, in order to be able to use, the need to log on to the Web page to initialize, configure.

1) first visit, login.

Open the browser and go to the address ip:8080, where ip server for the installation of Jenkins's real ip.

Note: If you ip:8080can not access, it may be due to the 8080 port is not open, Jenkins server firewall can be turned off.

[root@xcbeyond ~]# systemctl stop firewalld.service

Here Insert Picture Description

Tip the page to enter the administrator password, the /var/lib/jenkins/secrets/initialAdminPasswordfind the password, enter the password, click [Continue] button to initialize, wait a moment, will enter the "Getting Started" page.

2) install the plugin.

Here I chose to install the recommended plugins [], to complete the selection Jenkins plugin, as shown below:
Here Insert Picture Description

Then you start the plug-in installed, wait until done, click [continue] operation. (This process is relatively slow, a cup of tea, wait ...)

(The installation process, there may be some plug-in installation fails, you can choose to retry [] or [] to continue operating, because the plug-in the course of subsequent use is also possible in succession to install.)
Here Insert Picture Description

3) create an administrator user, click [Save and Finish.
Here Insert Picture Description

4) Examples of the configuration.

Tip Configuration Jenkins URL, here you can keep the default, continue to click [Save and Finish.
Here Insert Picture Description

So far, Jenkins has been installed ready for normal use.
Here Insert Picture Description
Here Insert Picture Description

Reference article:

  1. https://jenkins.io/zh/doc/
  2. https://pkg.jenkins.io/redhat-stable/
Published 141 original articles · won praise 568 · views 570 000 +

Guess you like

Origin blog.csdn.net/xcbeyond/article/details/104909939