javamavenjenkinsmaven-3sqljdbc

Failed build in Jenkins: cannot resolve sqljdbc4 jar


I have started configuring Jenkins with my project. I made sure to install the sqljdbc driver in my local repository first:

$>mvn install:install-file -Dfile=sqljdbc4-4.0.jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0 -Dpackaging=jar

I can see the jar has apparently been installed successfully at:

C:\Users\ me \.m2\repository\com\microsoft\sqlserver\sqljdbc4\4.0

This is what the pom relevant parts looks like:

    <sqljdbc4.version>4.0</sqljdbc4.version>


    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>sqljdbc4</artifactId>
        <version>${sqljdbc4.version}</version>
    </dependency>

However when I try to build the project from jenkins I get:

Executing Maven:  -B -f C:\Program Files (x86)\Jenkins\jobs\Build Solutions Project\workspace\pom.xml install
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building CommonFrontPage 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://repo.maven.apache.org/maven2/com/microsoft/sqlserver/sqljdbc4/4.0/sqljdbc4-4.0.pom
[WARNING] The POM for com.microsoft.sqlserver:sqljdbc4:jar:4.0 is missing, no dependency information available

I'm not sure why it's not looking in my local repository first.

I also set under "configure" > "Maven Project Configuration":

Local Maven Repository Default (~/.m2/repository)

I restarted the Jenkins service too.

I am not sure how to proceed from here.

I know I could use nexus, but I don't really need it at this stage.

Maven version: 3.0.5


Solution

  • I managed to solve it. Since it was building correctly checking out the repository and using maven from the command line, I figured Jenkins was using a different configuration to resolve the repository, so I explicitly added:

    C:/Users/me/.m2/repository

    into maven's "setting.xml".

    Not sure if it's the most elegant solution but at least it works now.