Jenkins whole process to build

Chapter 1 Overview

 Continuous Integration (CI) is a practice designed to ease and stabilize the building process of software. Continuous integration was first proposed by Martin Fowler 10 years ago, and it is hoped that the following processes can be achieved through continuous integration:

Ø Anyone, anywhere, can build the entire project at any time.

Ø In the continuous integration build process, every unit test must be executed.

Ø In the continuous integration build process, every unit test must pass.

Ø The result of a continuous integration build is a release-ready package.

Ø When any of the above points cannot be satisfied, the main task of the entire team is to solve this problem.

Jenkins is a very popular open source CI server in the software industry. Here are some basic introductions.


Chapter 2 Basics

2.1  Jenkins installation

2.1.1 Resource download

First download the installed version of Jenkins from http://Jenkins-ci.org/ . Double-click the installation file to install (jar package installation is not recommended);

In addition, you also need to download the jdk installation package, it is recommended to version 1.5 or above;

2.1.2 Prerequisites for running Jenkins

1) Setting of environment variables (required options in italics):

a) JAVA_HOME, set the installation directory of JDK, it is recommended to use JDK1.5 or above

b) ANT_HOME, set the directory of Ant, it is recommended to use the latest version of ant 1.8

c) JENKINS_HOME, set the Jenkins configuration file directory, the default is the user's directory, it is recommended to be the Jenkins installation directory for easy control;

d) PATH, you need to configure the java and ant directories to the path directory;

e) CLASSPATH, you need to configure the tools.jar of JDK to CLASSPATH;

2) Other external conditions ( not necessary )

a) The jar files for remote control of WebLogic923 are required. The files include three jar files: weblogic_sp.jar , weblogic.jar and webservices.jar . These three files are located in the relative directory server\lib of the WebLogic installation directory;

b)         Configure the above three jars into the CLASSPATH environment variable of the system;

2.1.3 Jenkins start

1) For the installation of Jenkins.war, there are two ways to run Jenkins;

a) directly from the command line

Go to the directory where Jenkins.war is located, currently D:\Jenkins

java -jar Jenkins.war --httpPort=8080 –prefix=Jenkins

Note: httpPort is the port where Jenkins runs, and the default port is 8080. The above command actually runs in the Winstone container;

b) run in a web container

Jenkins can run in a standard web server, and supports Tomcat, Jboss, and WebLogic. You only need to place Jenkins.war in the corresponding directory and start the service to access it;

2) For jinkens installed as a service, enter http://localhost:8080 in the address bar by default to enter its homepage;

2.1.4 Jenkins access

Verify that Jenkins is running properly by visiting http://hostIP:port/Jenkins .


2.2  Jenkins basic settings

  The basic settings of Jenkins are in the background settings of the system, similar to the Windows control panel.

2.2.1 Set JDK (System Management->GlobalTool Configuration)


2.2.2 Set ANT (System Management->GlobalTool Configuration)

You can set ANT_HOME here. If the system has already set ANT_HOME, you don't need to configure it, and you can let Jenkins install the latest ANT.

Note: In order to make the configuration easier, it is recommended to set JAVA_HOME and ANT_HOME at the system level to facilitate system migration.

2.2.3 Configure Email Information (System Management -> System Settings)


The system can send the result email after the execution plan is completed. You need to configure the relevant information of the email server:

It is also necessary to configure the URL address of Jenkins as a later access address. Once the URL is set, do not modify it easily.


2.2.4 Create a project example

Click "New Task" in the Jenkins main menu, and the following figure appears:

Type in the task name, select the " Build a free-style software project " option, and click the "OK" button, the following interface will appear:

illustrate:

a) Project name (Projectname): The project (task) name cannot be repeated, and it is referred to as the task in the following;

b) Description: a brief description of the task;

c) Discard old builds: Whether to keep past builds, the default is to keep. (Help: This controls how long you want to store build records on the disk where Jenkins is located (such as console output, build artifacts, etc.). Jenkins provides two criteria for this: 1. Time driven. In Jenkins you Can tell if a certain time limit is reached to delete a record (e.g. seven days ago). 2. Quantity driven. In Jenkins you can make sure it has N builds. If a new build starts, the oldest one (record) is will be deleted. Jenkins also lets you define individual builds that you build as 'keep this record forever' in order to prevent certain important builds from being automatically discarded.)

d) Thisbuild is parameterized: If this option is selected, Jenkins will allow you to provide an arbitrary set of key-value parameters that will be passed into the build process. The configured parameters are often some environment variables in the build runtime environment. (Help: When you're using Jenkins' various automations, sometimes requiring input from a set of users during the build process, using "parameterize" makes the build easier. For example, you might set up an on-demand test where users A zip file of the binary can be submitted for testing.

e) DisableBuild: disable this task from building, the default is not disabled;

f) Execute concurrent builds if necessary

g)        Advanced Project Options

1) Quiteperiod: Waiting time before construction;

2) RetryCount: The time of taking the attempt from the SCM warehouse;

3) Blockbuild when upstream project is building: If the previous one is still in the construction process, stop this build task;

4) Usecustom workspace: Specify the workspace of the current task, otherwise the default is the working directory of JENKINS_HOME

h) Source Code Management: Specify how to obtain compiled source code:


1) None: Manual mode;

2) Git: Fetch from Git repository;

3) SVN: Get it from the SVN repository;

a) Builds Triggers: Set build triggers

1) Trigger a remote build

2) Buildafter other projects are built: Set up the build pipeline and configure the task to be built automatically after the set task is built. After setting, you can see the following "downstream project description" in the task overview (operation steps are omitted)

1)    Build peridically

2) Github hook trigger builds remotely (eg, fromscripts): Set remote trigger for task builds;

3) Build periodically: Set the build frequency, which is the same as the QuartzCronTrigger setting;

4) PollSCM: Set to check if the source code is updated from the SCM repository:

Remarks: Regarding the fifth and sixth points, the basic configuration is

Minutes Hours Day Month Week

Example: Integration every minute * * * * *, Integration every 5 minutes 5 * * * *, Integration every day at 12:00 and 23:00 12,23 * * *

a) Build Environment: Set the build environment settings

1)    Deleteworkspace before build starts

2)    Abortthe build if it`s stuck

3)    Addtimestamps to the Console Output

4)    Usesecret text(s) of file(s)

b) Build: Execute the build

Build supports 6 ways, shell (running in Linux environment), Maven (supporting Maven compilation), Command (windows batch command), Ant, EasyAnt, Export job runtime parameters.

Example:

1)    InvokeAnt:

Remark:

Ø Targets is mainly to execute which parts of the ant script, and multiple can be added;

Ø BuildFile: The physical location of the Ant script needs to be specified;

Ø Properties: Add the properties specified by Ant;

Ø JavaOptions: Set properties when running java, such as memory, heap size, etc.;

2)    ExecuteWindows batch command


Note: To execute Windows batch commands, variables set by Hodson cannot be used here;

a) Post-build operations

1) PublishJavadoc: Set the file directory when JavaDoc is generated during construction;

2) Archivethe artifacts: Set which files need to be archived after the build;

3) E-mailNotification: Email reminder

Remarks: You can send emails to multiple people, which can be divided by " ; "

4) StatusMonitor: build status monitoring;

2.2.5 End of configuration

Well, the basic configuration is over here, you can build a new task to build.

2.3 Run and monitor build jobs

2.3.1 Main Control Panel

When the configuration completes a task, go back to the main control panel:

Ø The list on the right in the above figure lists the currently configured tasks and the current status of the tasks

Ø There is a build queue on the left, when there are components, the queue currently under construction will be listed on it;

Ø There is RSS subscription in the lower right corner of the above picture, which supports subscription all, failure and last time, etc.;

2.3.2 Manually build a task

When a task is configured, it can be built manually or with a trigger. During the project verification stage, you can manually trigger and click "Build Now" in the task area, and the following progress bar will appear in BuildHistory:

Click the progress bar to enter the specific compilation process, such as the following figure:

After the build is complete, you can see the result graph of the latest task build:

The overall health of the browse task is shown in the following figure:

The leftmost column shows the last build status, and the second column shows the overall build result of the entire task, as shown below.

2.3.3 Task build status

Jenkins passes current build status and build stable new

Ø The current build status is divided into the following

 

The project is built and considered stable

 

Project build completes but is considered unstable

 

build failed

 

Job has been banned

Ø Build a stable line, Jenkins will issue a robustness index (from 0-100) for the build based on some post-processor tasks, the higher the more stable

 

Build success rate>80%

 

Build success rate 60%-79%

 

Build success rate 40%-59%

 

Build success rate 20%-39%

 

Build success rate 0-19%

Expect task compilation to be in and state.


Guess you like

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