Jenkins Installation and Configuration

Source: Internet
Author: User

Pre-installation concerns:

Q: Which version of Jenkins should I choose?
A: If you are officially using the recommended long-term support version (LTS), Reason: stable. If you are learning, whichever version you can.

Which version of Q:JDK should I install?
A: Recommended installation of JDK7, Reason: Some plugins must require JDK7 support. For example: monitoring plug-in

Which version of Q:tomcat should I use?
A:tomcat6 or 7 can be. If you're going to use the Tomcat5.5 version, there's a bunch of weird bugs that can make you dizzy.

One, install Jenkins in the Windows environment

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, the fate of the line run Java-jar Jenkins.war (by default, the lower port is 8080, if you want to use a different port to start, can be modified by the command line "Java–jar Jenkins.war--httpport=80")

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):

Second, Jenkins Configuration

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 to see. English will not use translation tools, test more than a few times, you understand.

2.1 System Management

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

2.1.1 Tip Information

Ps: Messages with different prompts may be different

2.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

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

2.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!

2.1.1.3 Security Settings

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.

2.1.2 System settings

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

The root directory of the Ps:jenkins, which is C:\Documents and Settings\aaa\.hudson by default.

2.1.2.1 JDK, Maven, ant configuration (pictured as Windows environment)

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.

Click "Install" to add the appropriate settings, such as:

JDK aliases: show you, whatever you want.

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

Note: Ant, maven configuration is the same (JDK to Oracle website download, Ant and maven to the Apache website download)

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

2.1.2.2 Mail Notification configuration (default) 2.1.2.2.1 Configure Sender Address

System Admin e-mail address: Jenkins Mail send address, remember, must be set.

2.1.2.2.2 Configuring mail Notifications

Settings: SMTP server, check "Use SMTP Authentication", enter user name and password

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

2.1.2.3 Subversion Configuration

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

2.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:

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.

This setting: only the logged-on user can do anything

2.1.4 Managing user Settings

In the top right corner, click Register

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:

2.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.

Requirement: 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

2.2 Project Build Settings 2.2.1 Build free-style Job2.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:

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.

It is important to note that:
1.Job name never use Chinese name (Do not die).
2. It's best to have a plan when creating the job name, because we'll end up with a regular match to automatically categorize the job, such as I like the "Item current prefix _ Some description-job type" approach.

2.2.1.2 Build Task Configuration 2.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:

After the setup is successful, get the files directly from the SVN directory to local. Ps: To add credentials first. Here's how to add the following:

Click on the credentials on the left of Jenkins home page to enter

Next: The user name and password are generally used to log in

PS:SVN user name and password settings are no way to modify the Web interface. If you want to modify it, go to the Jenkins directory to delete the Hudson.scm.SubversionSCM.xml file

2.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.

2.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.

Ps: 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

2.2.2 Build maven-style job (this block I did not get) 2.2.2.1 new Maven Build task

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,

2.2.2.2 Building a task configuration

2.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:

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

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)

2.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.

2.2.2.2.3 Maven Build Settings

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

2.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

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.

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

2.2.3 Mail Notification settings

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

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

2.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:

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

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.

2.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.

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.

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.

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.

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

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

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:

Third, Jenkins plug-in

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.

3.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:

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:

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.

3.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.

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

Original: https://www.cnblogs.com/yangxia-test/p/4354328.html

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.