简体   繁体   中英

external maven repo and jenkins

I have an external jar(meaning not available in a public repo), that i want o include in my build. I used the instructions found on this site: http://charlie.cu.cc/2012/06/how-add-external-libraries-maven/ and it works, when I do mvn install in my PC. But when I am building the maven project using Jenkins, i get the following error:

Executing Maven: -B -f D:\\Program Files (x86)\\Jenkins\\workspace\\rmy job\\pom.xml install [INFO] Scanning for projects... [INFO]

[INFO]

[INFO] Building xxxxxx 0.0.1-SNAPSHOT [INFO]

[WARNING] The POM for sqljdbc:sqljdbc_4.0:jar:v4 is missing, no dependency information available

[INFO]

[INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total

time: 1.705s [INFO] Finished at: Tue Feb 11 10:29:23 EET 2014

[INFO] Final Memory: 13M/307M [ERROR] Failed to execute goal on project xxxxxx: Could not resolve dependencies for project com.xx:xxxxxxx:jar:0.0.1-SNAPSHOT: Failure to find sqljdbc:sqljdbc_4.0:jar:v4 in http://repository.codehaus.org/org/codehaus was cached in the local repository, resolution will not be reattempted until the update interval of codehaus has elapsed or updates are forced -> [Help 1]

The pom that i am using has these entries for repositories:

    <repositories>
<repository>
    <id>codehaus</id>
    <url>http://repository.codehaus.org/org/codehaus</url>
</repository>

<!-- In Project repository -->
<repository>
    <id>in-project</id>
    <name>In Project Repo</name>
    <url>file://${project.basedir}/libs</url>
</repository>

Any ideas why this is happening?

After some tries, i did the following workaround in pom.xml

<repository>
    <id>in-project</id>
    <name>In Project Repo</name>
    <url>file://${project.basedir}/libs</url>
</repository>

and

<dependency>
    <groupId>sqljdbc</groupId>
    <artifactId>sqljdbc_4.0</artifactId>
    <version>v4</version>
      <scope>system</scope>
    <systemPath>${project.basedir}/libs/sqljdbc/sqljdbc_4.0/v4/sqljdbc_4.0-v4.jar</systemPath>
</dependency>

This means that the system path is needed as a whole and not just

 <url>file://${project.basedir}/lib</url>

as it was mentioned above. By this "workaround" I got it to work both locally and remotely (Jenkins-Git)

As a general rule I always strongly recommend to

  • use a Maven Repository Manager such as Nexus
  • only manage repositories in the Maven Repository Manager, not in the POMs
  • use the Maven Repository Manager to host third-party libraries not available from any other repository
  • configure your settings file

This is a key to get stable and reproducible builds - even when one of the repositories is temporarily unavailable.

Actually that might be hppen that it can't get the jar from lib.

tyr it with other way.

  1. right click project
  2. select property
  3. java build path
  4. select Lib
  5. add external jar and put set path of your jar files
  6. finish
  7. clean and build your project.

OR

    <repositories>
        <repository>
        <id>local123</id>
        <name>localRepo</name>
        <url>file://${project.basedir}/lib</url>
        </repository>
     </repositories>

try putting this code in pom.xml file.

hope your problem can be resolve using this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM