To discuss these components in detail. The automatic CI building process often integrates software, which needs to be completed by building. Ant is a common building platform in the Java environment. Ant can be used to automatically execute compilation, testing, and other tasks reliably, or even perform software inspection and deployment. After you have mastered all the components of Ci, you will find that building a strategy is the most important aspect of the successful CI process. If an appropriate building process is missing, CI cannot play a role. Source code management requires a source code management (SCM) system or repository, such as subversion or CVS, to make CI play its role correctly. The CI server queries the SCM repository for code modifications. When a change is found, the CI server performs the check-out (updating the local sandbox) and the build. In addition to more frequent execution, the build process is the same as the build performed in the local environment. For successful CI processes, the CI server must use an automatic process to monitor the SCM repository and run the build when the modifications are detected. This is also important. For the Java platform, there are many available CI servers, including open source software and commercial products. Their basic configurations are similar and suitable for monitoring specific SCM and building when modifications are detected. All CI servers have their own advantages and disadvantages. Hudson is particularly interesting because it is easy to configure and has powerful plug-ins that can display testing result trends and other information.Ii. Hudson Introduction
Hudson is a revolutionary open-source CI server that has learned a lot from its previous CI servers. One of the most attractive features of Hudson is its ease of configuration: it is difficult to find a CI server that is easier to set, and it is also difficult to find a CI server with such rich out-of-the-box features. The second reason Hudson is easy to use is that it has a powerful plug-in framework, so it is easy to add features. For example, a Hudson plug-in can track findbugs and code overwrite over time. It can also report the trend of test results (from JUnit or testng) and build results and corresponding execution time.
Hudson needs to run Java 5. To use a container other than the embedded container (Winstone) that comes with Hudson, you only need to use a servlet 2.4 container. Winstone is sufficient in most cases.
3. Use Hudson
The last aspect of the Ci process is the CI server itself. The main role of the Ci server in the entire development process is the Controller: when the server detects modifications in the code repository, it delegates the build task to the build process itself. If the build fails, the CI server notifies related parties and continues to monitor the repository. Its role seems passive; however, it is the key to quickly reflect the problem.
Install Hudson
One of the main advantages of using Hudson is that it is easy to set. In the simplest case, Hudson only needs two steps:
- Download the latest version (which is packaged as a war file ). Hudson Official Website: https://hudson.dev.java.net/
- Run
java -jar hudson.war.
In this way, you can. Because the download is a war file, you can deploy it in Tomcat, JBoss, and other containers if you want. This is entirely up to you. Of course, Hudson assumes that Java 5 is running on the machine where it is installed, and ifJAVA_HOMEEnvironment variable, Hudson will use it. (As mentioned above, Hudson needs Java 5 .)
After installing and running Hudson (deploy the war file to the servlet container or executejava -jar hudson.war), Start the browser and access the default installation location. If you run Hudson through the command line and you are on a local machine, you can accesshttp://localhost:8080/.
If everything is normal (in fact, it is unlikely that a problem occurs), you will see the Hudson startup page shown in figure 2.
Configure Hudson
If you access the local instance on the Hudson homepage and click the manage Hudson link in the upper-left corner, you will see a list of configurable options shown in figure 3.
Figure 3. Easy to configure Hudson
Parameter description:
System. Message enter instructions
Quiet Period: the time (in seconds) for Hudson to regularly build the project)
Enable Security: Set Hudson logon rules (Anonymous logon by default)
TCP port for JNLP slave agents: I don't know what JNLP is. In short, there are three methods: fixed (fixed) random (Radom) not used (Disabled). When fixed, JNLP information can be entered.
Security realm: You can use middleware containers, databases, and LDAP to verify security. The specific usage is useless and will be updated in the future.
Authorized: authentication methods that allow you to set identities: system users, anonymous users, Custom Users, and inherited users (anonymous users are also recommended in this study)
JDK installations: Set the JDK installation path
Shell executable: Set the window shell command
Ant installation: Set the installation path of ant
Set Mave installation path
CVS executable: Specifies the execution path of the cvsnt(cvs.exe)
. Cvspass file: set the path of the cvsnt administrator file (passwd file)
E-mail Notification: Set the email address sent when an error occurs.
Hudson URL: the default address of Hudson.
You can also configure other aspects of the server, such as providing the location of an email server to Hudson to receive emails when the build fails. You may need to ask the system administrator to help set this feature based on your organization's email setting method. Setting email is not required; Hudson also supports RSS as a notification mechanism, which is better for some people than email. The notification mechanism you choose depends on you. (Note: here we are talking about "what", that is, multiple notification mechanisms can be used at the same time !)
Configure a project in Hudson
Now that Hudson can communicate with the SCM repository, the configuration item is ready. The project used in this example is calledsolar-ci. On the Hudson homepage, click the new job link in the upper left corner. The screen shown in Figure 5 is displayed:
This page allows us to use Hudson to manage a corresponding project in CVS
Project name: Project name
Description: Description
Discard build: If this option is selected, you can set the number of days for saving the build record, the number of days for saving the build record, or only the latest build record.
Advance project options: You can set the interval for Hudson to regularly check the CVS project. You can also specify the local project path for the CVS project check.
Source code management: When we select CVs, the following parameters are displayed:
Cvsroot: Enter the CVS login string in the format (: Protocol: User: [email protected]: Path), for example: : Pserver: cvsadmin: [email protected]: 2401:/cvsnt/Repository, required for CVS
Modules:Enter the specific project name under the CVS repository, which is required by CVS.
Branch: Enter the branch name. You can also select this is a tag. No a branch specifies the tag name.
Select subversion to set the corresponding subversion.
Build triggerYou can set some actions automatically executed by Hudson. Build after others projects are built specifies the name of the project to be built after the Hudson build is complete.
Build periodicallySet the time interval for automatically building a project based on the syntax rules defined by Hudson
Post-build actions
Set the actions after the build, such as sending emails, packaging, generating test reports, and generating Java Doc.
Click OK to save settings
Use Hudson
Go to the project you Just configured, And you can view the historical build records in build history on the left. Click build now to manually execute the build action. After the build action is completed, you can check whether an error occurs by recording the marked color, red is wrong. Blue is successful. click record to View Details. If there is any change, Hudson will list class information
Elipse plug-in Application
Eclipse updatesite: http://code.google.com/p/hudson-eclipse/
In eclipse, the Hudson option is displayed under Windows-> preferences, and the default Hudson URL is set to save.
Select Windows> open view to open Hudson view.
If you have configured the Hudson project, the name of the Hudson project will be listed. Right-click the menu and you will see all the execution menus. It is very convenient to use. I hope you can improve this article.