jenkins build maven project: local dependencies solution can not be found

Reprinted: https://www.cnblogs.com/yy-cola/p/9664598.html

Preface:

         When we build maven project, often use some special jar package (can not be downloaded in a central warehouse directly to the local maven repository such as Microsoft does not allow the direct download com.microsoft.sqlserver: sqljdbc4: jar: 4.0 jar, etc. package), we can only manually download the package into this part of the jar maven local repository to reference. .

 

Can be normal to build a project before deployment, development today changed the pom file, modify the package a jar of local reference, leading to jenkins build fails, then this record

Pom file before modifying the relevant part:

The revised pom file the relevant part:

  • The first reference jenkins will find the specified directly from the jar package under the path pom configuration file to compile the project folder
  • The second way, jenkins default maven remote repository to find dependencies, but no remote repository is this package, and therefore error. Figure:

 

Solution: ① first jar package to the command-line installation maven local repository:

 
 
The jar package stored in a directory, for example: c: /db2jcc.jar (Dfile)
DgroupId DartifactId Dversion Dpackaging: The first three pom file as the last one is the final installation of the jar package name warehouse
install-file -Dfile=c:/db2jcc.jar -DgroupId=db2 -DartifactId=db2jcc -Dversion=1.0  -Dpackaging=db2jcc-1.0.jar

② View maven local repository will be installed successfully find a jar

 

 FIG case ③ follows disposed jenkins project configuration, as used herein, is meant -Dmaven.repo.local, specify the path to a local repository,

这样编译的时候,如果maven在远程中央仓库找不到指定的jar包会去本地仓库找(本地仓库的路径默认是这个,但开发存放jar包的地址可能不是这个,需要找开发确认)

clean package -Dmaven.repo.local=C:\Users\Administrator\.m2\repository

最近遇到一个新的知识点,这个地方其实就是为maven打包做一些配置的,还可以跳过测试:

clean package -Dmaven.repo.local=C:\Users\Administrator\.m2\repository -Dmaven.test.skip=true

Guess you like

Origin www.cnblogs.com/hanjun0612/p/12107241.html