Jenkins+Maven+SVN quickly builds a continuous integration environment

 

1. Download the war package on the official website, open http://localhost:8080/jenkins/ , there is no data in it for the first time, we need to create a job, we have 2 projects, and we need to create 2 jobs.

2. Click on new job in the upper left corner. On the new job page, you need to select the type of job. Jenkins supports several types. We choose "Build a maven2/3 project". The job name is: guan_caijing, as shown in the figure:

image

3. After clicking the OK button, you will enter the detailed configuration interface. There are many configuration items in the detailed configuration interface, but don’t be afraid, most of them can use the default configuration. Here are a few places we need to modify:

3.1)Source Code Management

Because we use SVN to manage the source code, so choose Subversion here, and enter our SVN address in the Repository URL:

svn://*****************

After entering the URL address of the SVN library, Jenkins will automatically verify the address and give a prompt.

clip_image004

Click the enter credential link in the red font part to enter the following page:

clip_image006

After setting the user name and password to access the SVN library, click the OK button to display:

clip_image008

The setting is successful. Click the Close button to return to the previous Source Code Management page. There are no more red warning messages at this point.

clip_image010

 

 

3.2) Configure automatic build

3.3) Configured here, someone may find that in the Build configuration node, there is a red error message, prompting

Jenkins needs to know where your Maven2 is installed.
Please do so from the system configuration.

as the picture shows:

clip_image014

This is because Jenkins cannot find maven, click "system configuration", it is OK to add the maven directory to the maven configuration of the system configuration, as shown below:

clip_image016

I set the installation directory for JRE 6 and MAVEN 3.

Click the SAVE button in the lower left corner to save the settings.

3.4) After saving all the configurations, our first job is completed.

3.5) Create a second job with the same configuration as above. Just change the svn address to: http://localhost/svn/Web

3. Manual build

After the above configuration, go back to the Jenkins home page, you can see the 2 jobs just added on the home page, as shown below:

clip_image018

Click on the "Schedule a build" picture behind a job to build manually. After clicking, the task under construction will be displayed in the Build Queue or Build Executor Status on the left . After the automatic build is completed, refresh the page to see The build result is completed. If a project fails to build, click the build number behind the project (incrementing from 1) to enter the " Console Output " of the project to view the reason why the project failed to build. Of course, we can also configure to send the result of the build failure to the mailbox.

So far, a simple automatic build environment has been set up, very simple.

Fourth, automatic deployment

After reading the above, I found that the Jenkins configuration is really simple. The automatic build environment was set up in a few minutes, but after the environment was set up, I found a problem. Now it can be built automatically, but the built web.war is still in the Jenkins directory. , and it is not published to tomcat, do you need to copy it manually?

This is a problem, but don't worry, to achieve the purpose of automatic deployment, you need to install a Jenkins deployment plugin. Select Manage Plugins from the System Administration menu:

clip_image020

Select "Optional Plugins", find the Deploy Plugin 1.8 plugin, and select it.

clip_image022

Note: Deploy Plugin 1.8 plugin supports Tomcat 4.x/5.x/6.x/7.x, JBoss 3.x/4.x, Glassfish 2.x/3.x

Clicking the "Install" button at the bottom shows:

clip_image024

Wait patiently:

clip_image026

Until the Deploy Plugin completes, showing Success:

clip_image028

Check the box and Jenkins will restart automatically:

clip_image030

At this point, on the "Installed" tab page of the plugin management, you can see that the deployment plugin has been installed.

clip_image032

Re-enter the configure configuration interface of the web, and you will find multiple configuration items at the bottom. We configure as follows:

Jenkins deploys web projects to remote tomcat (4)

We add a deploy war/ear to a container option, and a post-build operation in Jenkins adds a release option
Jenkins deploys web projects to remote tomcat (4)
WAR/EAR files: is the relative path of the war package

Click add contaners to add the published container, we want to publish to tomcat here, so what I add here is tomcat

Jenkins deploys web projects to remote tomcat (4)
Jenkins deploys web projects to remote tomcat (4)

If you are deploying a cluster environment then you can add multiple containers to deploy the application.

 

Special reminder: 1. The configured tomcat must be started, and the user name and password must be configured, such as: tomcat-user.xml

 <role rolename="tomcat"/>

  <role rolename="manager-script"/>

<role rolename="manager-gui"/>

<role rolename="manager-status"/> 

<role rolename="admin-gui"/>

<role rolename="admin-script"/> 

<user username="tomcat" password="tomcat" roles="manager-gui,manager-script,tomcat,admin-gui,admin-script"/>

 

 

Guess you like

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