Jenkins Introductory series--02 chapter II Jenkins installation and configuration

Source: Internet
Author: User

2014-12-08: No longer positions as SCM and CI, Jenkins articles are no longer necessary to maintain.

Write I want to vomit blood, exhausted.

Web page look uncomfortable, to download the PDF yourself. If you have any questions please leave a message!

The--03pdf document download for the Jenkins Starter series

Chapter II Jenkins installation and configuration 2 Jenkins installation

In the simplest case, Jenkins requires only two steps:

1. Download the latest version (a WAR file). Jenkins Official website: http://Jenkins-ci.org/

2. Run Java-jar Jenkins.war

Note: Jenkins needs to run Java 5 and the above versions.

Another way to install it is to deploy the downloaded War package file to the servlet container, then launch the container and enter an address like http://localhost:8080/jenkins/in the browser's URL address bar. is the interface after successful installation (using the LINUX+TOMCAT6+JAVA6 environment):

Figure 2 Jenkins main interface

3 Jenkins Configuration

Write before the configuration of some words: Jenkins configuration can not all say, most of the configuration is in English, click the question mark on the back of the input box can be seen. English will not use translation tools, even the band guess, more test several times, you understand.

3.1 System Management

On the already-running Jenkins home page, click System Management on the left to enter the following screen:

Figure 3 Jenkins System Management

3.1.1 Tip Information

Ps: Messages with different prompts may be different

3.1.1.1 Utf-8 Encoding

Your container doesn ' t use UTF-8 to decode URLs. If non-ascii characters as a job name etc, this is cause problems. See Containers and Tomcat i18n for more details.

Jenkins recommends using UTF-8 encoding in tomcat to configure the Server.xml file for conf directory under Tomcat

Figure 4 uriencoding encoding settings

Ps: If the job's console Chinese output is garbled, change uriencoding= "Utf-8" to Usebodyencodingforuri= "true"

3.1.1.2 the new version

New version of Jenkins (1.518.jenkins-14362-jzlib) is available for download (changelog).

Tip There is a new version can be downloaded, like the updated click Download to download it!

3.1.1.3 Security Settings

Figure 5 Security Tip Message

Jenkins allows anyone on the network to start a process on your behalf. Consider enabling at least authentication to prevent misuse. Click Dismiss to ignore the message and click on Setup security to enter the settings screen. Please refer to the Configure Global Security Settings section for detailed settings.

3.1.2 System settings

On the already-running Jenkins home page, click System settings on the left to enter the following interface:

Figure 6 System Setup Interface

3.1.2.1 JDK, Maven, ant configuration

To configure a JDK, Ant, maven instance, click the Add button below each section, where you will add the name and absolute address of the instance. Describes these two sections.

Figure 7 JDK Configuration Interface

JDK aliases: show you, whatever you want, call puppy.

Java_home: This is the installation path of the native JDK (the wrong path will be prompted with a red letter)

Automatic installation: This option is not recommended

The following Ant and Maven configuration is the same, JDK to Oracle website download, Ant and maven go to Apache official website download

Ps: There is a question mark after each text box, click the question mark will appear the Help information

3.1.2.2 Mail Notification configuration 3.1.2.2.1 Configure sender Address

Figure 8 Sender Address Configuration Interface

System Admin e-mail address:jenkins email address, if you do not configure, waiting to send an error when sending an email, then I also here is not configured, depressed me a week of time. ⊙﹏⊙ b Khan

3.1.2.2.2 Configuring mail Notifications

Figure 9 Email notification

This is very simple, based on the mailbox provider's parameter configuration is OK.

Ps: Tip: After the user's default message suffix is configured, you will need to fill in the email address only before the

3.1.2.3 Subversion Configuration

Figure Subversion Configuration

Subversion Workspace version:subversion Version number, choose your corresponding version number on the line

3.1.3 Configure Global Security (Safety settings)

On the running Jenkins home page, click System Management->configure Global security on the left to enter the following interface:

Figure 11 Security Settings interface

Settings such as, the option to manage users appears in system administration after saving. The Login/registration option will also appear in the upper right corner of the page.

3.1.4 Managing user Settings

In the top right corner, click Register

Figure 12 Registering the user interface

Click the Sign Up button to indicate that you are now logged in. Back to home.

After login and anonymous account see the first page there are several different, as shown in the red box:

Figure 13 User Login Interface

3.1.5 managing plug-in Settings

It is recommended that you read the Jenkins plugin section before you come back to install the plugin as shown below. This plugin deploys the generated artifacts (war or ear) to the main server.

Plugin Name: Deploy Plugin

Plugin Description: This plugin takes a war/ear file and deploys, a running remote application server at the end of a build

3.2 Project Build settings 3.2.1 Build free-style Job3.2.1.1 new free-style build task

On the already-running Jenkins home page, click on the new job on the left to enter the following screen:

Figure 14 Creating a new job interface

At this point, you need to specify a name for the new build task. (the task name entered here is: ant_test) There are several types of tasks to choose from, given the initial introduction, choose to build a free-style software project. For other types, it is often used to copy existing tasks, which are primarily intended to create new tasks based on existing tasks. Click the OK button,

3.2.1.2 Build Task Configuration 3.2.1.2.1 source Management configuration

The demo is a link to use Subversion, enter your project link in the repository URL, and if you don't have permission, you'll be prompted as follows:

Figure Subversion Configuration Interface

Click Enter credential enter the user name and password (I guess everyone is usually logged in with the username and password)

Figure Subversion Permissions Authentication Interface

PS:SVN user name and password settings are no way to modify the Web interface. If you want to modify, go to the Jenkins directory to delete the Hudson.scm.SubversionSCM.xml file (donuts, after all, this is just the introductory tutorial)

3.2.1.2.2 Building triggers

Build after other projects have been built: when the specified project finishes building, the build of this project is triggered.

Poll SCM: This is a common option in CI systems. When you select this option, you can specify a timed job expression to define how often Jenkins checks your source code repository for changes. If a change is found, the build is executed once. For example, filling in an expression with 0,15,30,45 * * * * will allow Jenkins to check your repository changes every 15 minutes.

Build periodically: This option only notifies Jenkins to build the project at a specified frequency, regardless of whether the SCM has changed. It would be helpful if you wanted to run some test cases in this job.

3.2.1.2.3 Ant build Configuration

Because my project was compiled and packaged with an ant script, I chose Invoke ant,ant version to choose the name of your ant configuration, and be careful not to choose default.

Figure map Ant build Configuration Interface

If your build script build.xml is not in the workspace root directory, or your build script is not called Build.xml. Then you need to set the path of the build File option in advanced to indicate your script. Note: is a relative path

Deployment please refer to: War File Deployment section

3.2.2 Build maven-style Job3.2.2.1 new Maven build task

Figure 18 Creating a new job interface

At this point, you need to specify a name for the new build task. (the task name entered here is: maven_test) There are several types of tasks to choose from, given the initial introduction, choose to build a MAVEN2/3 project first. For other types, it is often used to copy existing tasks, which are primarily intended to create new tasks based on existing tasks. Click the OK button,

3.2.2.2 Building a task configuration

Figure 19 Building a task Configuration interface

3.2.2.2.1 Source Management Configuration

The demo is a link to use Subversion, enter your project link in the repository URL, and if you don't have permission, you'll be prompted as follows:

Diagram Subversion Configuration Interface

Click Enter credential enter the user name and password (I guess everyone is usually logged in with the username and password)

Figure Subversion Permissions Authentication Interface

PS:SVN user name and password settings are no way to modify the Web interface. If you want to modify, go to the Jenkins directory to delete the Hudson.scm.SubversionSCM.xml file (donuts, after all, this is just the introductory tutorial)

3.2.2.2.2 Building triggers

Build after other projects have been built: when the specified project finishes building, the build of this project is triggered.

Poll SCM: This is a common option in CI systems. When you select this option, you can specify a timed job expression to define how often Jenkins checks your source code repository for changes. If a change is found, the build is executed once. For example, filling in an expression with 0,15,30,45 * * * * will allow Jenkins to check your repository changes every 15 minutes.

Build periodically: This option only notifies Jenkins to build the project at a specified frequency, regardless of whether the SCM has changed. It would be helpful if you wanted to run some test cases in this job.

3.2.2.2.3 Maven Build Settings

Figure Maven Build Configuration Interface

2013-08-22 supplement goals and Options:clean Install-dmaven.test.skip=true #加入了跳过测试的代码

Root POM: Fill in the location of your project's Pom.xml file, note: Is relative location, if the file does not exist, there will be a red word hint.

Deployment please refer to: War File Deployment section

3.2.2.2.4 Building a MAVEN project

Tips for building maven projects with Jenkins:

The build of a MAVEN project is cumbersome if your project is this structure. Well, congratulations! You can create a new job, because there is only one root. If your SVN address is: https://192.xxx/Pe_Project/root-pom, then root pom just needs to keep the default, because Jenkins can find the Pom.xml file under the workspace directory again

If your SVN address is: https://192.xxx/Pe_Project, then root pom needs to be specified as Root-pom/pom.xml, because Jenkins can then workspace/ Root-pom directory below find Pom.xml file

Figure MAVEN Project Structure Interface 1

This method of packaging is very simple, but when you use eclipse development you do not right-click Run AS->TOMCA boot, if you want to use this way, you can change Tomcat to jetty.

If your project is this structure, then it is very tragic to tell you that you have to build several jobs to build this project, because this project has 4 roots.

Figure MAVEN Project Structure Interface 2

The above method is cumbersome to pack, but when you use Eclipse development you can start with the right-click Run AS->TOMCA

3.2.3 Mail Notification settings

Figure 25 Post-build Operation interface

Select the Add post-build action, and then choose E-mail Notification, such as:

Figure 26 Recipient List Interface

Enter the recipient's e-mail address in recipients, if you use multiple recipients with "," comma-separated

3.2.4 War File Deployment settings

First you must install the Deploy plugin plugin and then configure the Tomcat-users.xml file in the Tomcat conf directory to add the following to the <tomcat-users> node:

<role rolename= "Manager-gui"/>

<role rolename= "Manager-script"/>

<role rolename= "Manager-jmx"/>

<role rolename= "Manager-status"/>

<user username= "username" password= "password" roles= "Manager-gui,manager-script,manager-jmx,manager-status"/ >

The username and password in the quotation marks can be replaced casually and will be used later.

Okay, back to the Jenkins project configuration page:

Figure 27 Post-build Operation interface

Select the Add post-build action, and then select Deploy War/ear to a container, such as:

Figure 28 Remote Deployment Configuration Interface

War/ear Files:war file storage location, such as: Target/test.war Note: relative path, target before is not/.

Context path: Content that needs to be entered when accessed, such as ofcard when accessed as follows: http://192.168.x.x:8080/ofCard/if empty, the default is the name of the war package.

Container: Select your Web container, such as TOMCA 6.x

Manager User name: Fill in the username content of the Tomcat-users.xml configuration

Manager Password: Fill in the password content of the Tomcat-users.xml configuration

Tomcat URL: Fill in http://192.168.x.x:8080/

Deploy on Failure: Build failure is still deployed, generally not selected

Note: Although this deployment method may cause a deadlock in tomcat loading. But it's also the simplest way to deploy. It would be nice if the card was restarted and the Java memory parameter of Tomcat could be increased to solve this problem.

Finally, don't forget to click Save Oh.

All right! To this project to get the source code, packaging, remote deployment, mail notification is complete.

3.3 Monitoring

Once the task is running, you will see that the task is running on the dashboard in the queue and on the current work home page. Both of these are shown below.

Figure 29 Home Monitoring (left), project monitoring (right)

Once the build is complete, the completed task will be displayed in three places.

You can see it on the control panel of Jenkins, such as.

Figure 30 Home Page Project interface

As shown above, you will notice that there are two icons that describe the status of the current job. The S column represents "the latest build status" and the W column represents "Build stability". Jenkins uses these two concepts to describe the overall state of a job:

Build Status: A mid-level symbol outlines the four possible states that a job will generate in a recent build:

Successful: The build is completed and is considered stable.

Unstable: Completed construction, but is considered unstable.

Failed: Build failed.

Disabled: Build is disabled.

Figure 31 Build State interface

Build Stability: When the build is completed in a job and an unpublished target artifact is generated, if you are ready to evaluate the stability of the build, Jenkins publishes a robust index (from 0-100) for the build based on some post-processor tasks, which are typically implemented as plug-ins. They may include unit testing (JUNIT), Coverage (Cobertura), and Static code analysis (FINDBUGS). Higher scores indicate a more stable build. The rating range for stability is outlined in the graduated symbols. The state of any build job (total score of 100) below 80 points is unstable.

Figure 32 Building a stability interface

You can also see it on the current job main interface, such as the lower-left section

Figure 33 Project Main interface

Some interesting entries are also included on the current job home page. The links on the left sidebar primarily control job configuration, delete jobs, build jobs. The links to the right section point to the latest project reports and artifacts.

By clicking on a specific build link in build history, you can jump to the build home page that Jenkins created for this build instance. Such as

Figure 34 Building a historical interface

If you want to monitor the progress of the current task through the view output interface. You can click console output (console outputs). If the work is done, this will show the static output generated by the build script, and if the job is still running, Jenkins will constantly refresh the contents of the page so that you can see the output when it runs. Such as:

Figure 35 Console output interface

4 Jenkins Plugin

From Jenkins existing functionality extensions or the new features that developers provide to Jenkins can be called Jenkins plugins. Some plugins can be added seamlessly to your build process, while others, such as SCM plugins other than CVS and subversion, require the support of the source control system.

4.1 Jenkins plug-in installation

The Jenkins Plugin Manager allows you to install new plugins, and update the plugins on your Jenkins server. The manager will connect to the online repository to retrieve the available and updated plugins. If your Jenkins server is unable to connect directly to external resources, you can download it from the Jenkins website.

On the already-running Jenkins home page, click on the admin plugin on the left to enter the following interface:

Figure 36 Plugin Management interface

It consists of four tags:

Update: The list shows that Jenkins has searched for available updates for some plugins. Each plug-in listed can be selected and applied for updates.

Optional installation: Lists all plug-ins that can be used for installation (not currently installed). Each of the plugins listed can be selected and installed.

Installed: The installed plugins are listed in the list.

Advanced: Allows you to make Jenkins connect to the online plug-in library by setting up an HTTP proxy. In addition, an upload device is available to install those plugins you have downloaded outside of Jenkins.

By default, Jenkins integrates the Maven2 plugin, and once the plugin has a new version, it will prompt to update the new version of the plugin.

If you want to install a new plugin, you can click the optional plugin in the tab page. Such as:

Figure 37 Optional plug-in interface

From the graph, the various Jenkins plugins are categorized according to the types described previously. You can select any of the Jenkins plugins you want to install, click the Install without restart button. After installation, all plugins are placed under the Plugins folder as the HPI suffix name. If it is advanced users can also develop their own plug-in to facilitate the use of specific projects.

Note: The container for the Jenkins deployment needs to be restarted after the installation is complete. This will make it possible to use the newly installed plugin.

4.2 Jenkins Plugin Installation Example

Jenkins runs the auto-Deploy war package into the servlet container and must install a plug-in to implement this feature.

Figure 38 Installing the plug-in interface

Figure 39 Plug-in Installation interface

Okay, here's the Deploy plugin plugin installation done!

Jenkins Introductory series--02 chapter II Jenkins installation and configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.