Jenkins builds Java projects with Maven

Source: Internet
Author: User

Jenkins builds the JAVA project environment with MAVEN

Download the appropriate Jenkins version package on official website;

Jenkins

http://mirrors.jenkins.io/war-stable/

JDK

Curl-l-O http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz

JDK SE

http://120.52.72.24/download.oracle.com/c3pr90ntc0td/otn-pub/java/jdk/8u141-b15/ 336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz? Authparam=1500723059_7dfe39db8f8c6b07c5430e2c96d713b0

Tomcat

Http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.5.16/bin/apache-tomcat-8.5.16.tar.gz

Maven

Https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz


Ii. deployment of the JDK MAVEN Tomcat environment;

/etc/profile

Export Java_home=/usr/local/java

Export path= $JAVA _home/bin: $PATH

Export classpath=.: $java _home/lib/dt.jar: $JAVA _home/lib/tools.jar

2. MAVEN Environment Variables

/etc/profile

Export Maven_home=/use/local/maven

Export maven= $MAVEN _home/bin

Export path= $MAVEN: $PATH

3. Set the Jenkins default directory

Cat >>/etc/profile << EOF

Export Jenkins_home=/opt/jenkins

Eof

4, version verification;

Source/etc/profile

# mvn-version

# java-version

5. Tomcat as Jenkins Service

Download Jenkins War package directly under Tomcat WebApps launch Tomcat

Third, "System Setup"-"Global Tool Configuration" set the required environment;

JDK Installation Settings Java_home

Maven Installation Settings Maven_home

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/9C/9E/wKioL1lzPRzzEf-gAAAZXeoYkDM276.jpg "title=" 22. JPG "style=" float:none; "alt=" wkiol1lzprzzef-gaaazxeoykdm276.jpg "/>

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/9C/9D/wKiom1lzPRyjCyLVAAAdHazWy_A105.jpg "title=" 23. JPG "style=" float:none; "alt=" wkiom1lzpryjcylvaaadhazwy_a105.jpg "/>



Third, "System settings"-"Management plug-in" Add Maven plugin

Maven Integration Plugin

Maven Integration Plugin Plugin

Iv. Creating a Maven project

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/9C/9D/wKioL1lzPRfBbodqAACTtuH3lqQ931.jpg "title=" 11. JPG "style=" float:none; "alt=" wkiol1lzprfbbodqaacttuh3lqq931.jpg "/>

1. Build default configuration can also be

Root POM

Pom.xml

Goals and Options

Clean Package

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/9C/9D/wKiom1lzPRfBJoy7AAAfCNEVLYY493.jpg "title=" 12. JPG "style=" float:none; "alt=" wkiom1lzprfbjoy7aaafcnevlyy493.jpg "/>

Maven Common Build Parameters

Mvn-dskiptests Clean Package Skip detection compilation

Packaging: MVN Package

Compilation: MVN compile

Compiling the test program: MVN test-compile

Empty: mvn Clean

Run Test: MVN test

Build Site Directory: MVN site

Build the Site Directory and publish: MVN Site-deploy

Install the current project's output file to the local repository: mvn install

2. Build the jar package


650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/9C/9D/wKiom1lzPRiz_OukAADSL93U-dY621.jpg "title=" 14. JPG "style=" float:none; "alt=" wkiom1lzpriz_oukaadsl93u-dy621.jpg "/>

650) this.width=650; "src=" https://s1.51cto.com/wyfs02/M00/9C/9D/wKioL1lzPRnDn_IYAADOqFtgNn4689.jpg "title=" 15. JPG "style=" float:none; "alt=" wkiol1lzprndn_iyaadoqftgnn4689.jpg "/>

Build a War package

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M00/9C/9E/wKioL1lzPRqyPmyWAAHbPY1mlkw945.jpg "title=" 16. JPG "style=" float:none; "alt=" wkiol1lzprqypmywaahbpy1mlkw945.jpg "/>

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/9C/9D/wKiom1lzPRvDHi4BAADETwUv3xQ227.jpg "title=" 17. JPG "style=" float:none; "alt=" wkiom1lzprvdhi4baadetwuv3xq227.jpg "/>


3, compile failure;

Mostly because of the pom.xml problem and the various Maven silos of the jar package dependencies, according to log prompts to retrieve troubleshooting;


Five

Post-build operation steps:

The way to publish can be used ansible Saltstack or shell mode can be, can be combined with their own business environment to define the way of publishing;


This article is from the "Logs" blog, make sure to keep this source http://51log.blog.51cto.com/6076767/1950061

Jenkins builds Java projects with Maven

Related Article

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.