Jenkins introductory tutorial (on) [transfer]

Reprinted from: https://www.cnblogs.com/yjmyzz/p/jenkins-tutorial-part-1.html

Jenkins is a visual web tool widely used for continuous construction. To put it more bluntly, continuous construction is the "automatic" compilation, packaging, distribution and deployment of various projects. Jenkins can well support project construction in various languages ​​(such as java, c#, php, etc.), and is also fully compatible with ant, maven, gradle and other third-party build tools, and can be seamlessly integrated with svn and git. Support direct integration with well-known source code hosting websites, such as github and bitbucket.

Jenkins official website address is http://jenkins-ci.org/ , Jenkins itself is developed in java language, so the machine where Jenkins is installed must have at least JDK, and it is recommended that git, ant, maven, gradle, groovy and other tools are also included Installed for easy integration with these build tools.

 

1. Installation and startup (the environment for this article is mac os)

It is very convenient to download the latest war package directly from http://mirrors.jenkins-ci.org/war/latest/jenkins.war  , and then extract it to a fixed directory even after the installation is complete.

Start method: java -jar jenkins.war is enough. If you want to start as a background process, change it to nohup java -jar jenkins.war &. During the startup process, it will decompress the war package to the ~/.jenkins directory , and generate some directories and configuration files. Interested students can enter this directory and study it by themselves.

 

2. Update and download plugins

After the startup is successful, browse http://localhost:8080/ (if it is not installed on this machine, please replace localhost with the corresponding ip of the server)

 

Refer to the picture above and enter the interface of Manage Plugins. Many functions of jenkins are completed by plugins. When starting for the first time, many plugins will prompt that they are out of date and need to be updated. It is recommended to upgrade to the latest version. At the same time, it is recommended to install the following plugins to facilitate support git projects and upload files to remote machines and execute remote shell commands.

git plugin

After the plugin is upgraded, restart jenkins for it to take effect.

 

3. Security settings

By default, Jenkins allows anonymous users to do anything, which means that anyone can use Jenkins to publish, which is obviously not secure enough. Jenkins supports multiple security authentication mechanisms. The following demonstrates how to set the most traditional username/password mode :

Referring to the above figure, enter the Configure Global Security interface

Referring to the settings in the above figure, the above settings probably mean that the user name and password authentication mechanism built in jenkins is used, and users are allowed to register, and anonymous users have administrative rights (when configuring for the first time, it is recommended to allow anonymous users to have administrative rights to avoid operation errors. , you cannot enter the jenkins management interface normally, and after other user permissions are set, remove the management rights of anonymous users)

After saving, there will be a sign up registration link in the upper right corner of jenkins, click it to register a user, refer to the following figure:

Then enter the security settings interface:

It can be seen that there is one more user of yangjm in the user list and has administrative rights. You can try to log in with the user name of yangjm. If it is ok, you can remove the administrative rights of anonymous users. In general, it is recommended to remove the allowed users. Check the registration (in practical applications, all user names are generally established in advance, and the publishing system is rarely allowed to register at will), after saving, visit jenkins again

It will force only logged in users to use it.

 

4. System configuration

Before formally creating a deployment project, there are several key parameters to be set, as shown below:

 

First is jdk

Followed by ant, maven parameters

If you need to package the gradle project, gradle should also be configured

For git-hosted projects, git configuration is essential

If you also need to run shell scripts and upload files to remote machines through scp during the deployment process, you need to configure the following

Note: The red mark 1 in the above figure is filled with the local ssh private key certificate, the red mark 2 is the access password of the certificate, if the certificate password is not set, leave it blank, and the Root Repository Path is the remote server's password. Upload root directory, hostname is the machine name (or IP) of the remote server.

 

In addition, there is a powerful publish over ssh, which can not only upload files to remote servers, but also remotely execute Shell scripts on the server. Please refer to the following configuration

Similar to the parameter settings of SCP, but this plug-in has an additional button of Test Configuration. If the parameters are correct, after clicking the button, it will try to connect to the remote server. If successful, it will display Success.

 

Author: Yang Guo under the Bodhi Tree
Source: http://yjmyzz.cnblogs.com 
The copyright of this article belongs to the author and the blog garden. Reprints are welcome, but this statement must be retained without the author's consent, and the original text should be given in a prominent position on the article page. Connect, otherwise reserve the right to pursue legal responsibility.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324768295&siteId=291194637