Raistlin
Raistlin

Reputation: 1127

Jenkins cannot find maven dependency from local repository

I have added a jar file to my local maven repository by mvn install: install-file which works fine on my local machine. This is the dependency in my pom:

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc6</artifactId>
    <version>${oracle.connector.version}</version>
</dependency>

When running mvn clean install on my machine, everything works just fine. Now I have a local jenkins instance running (on a Windows machine) which should build my project. The build runs into an error and jenkins says:

Could not find artifact com.oracle:ojdbc6:jar:11.2.0 in mirror1 (http://repo.maven.apache.org/maven2) -> [Help 1]

The project settings for jenkins looks like this: enter image description here

<?xml version="1.0" encoding="UTF-8" ?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=
"http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/
settings-1.0.0.xsd">
    <localRepository>${user.home}/.m2/repository</localRepository>
    <servers>
        <server>
            <id>nexusReleases</id>
            <username>deployment</username>
            <password>deployment123</password>
        </server>
        <server>
            <id>nexusSnapshots</id>
            <username>deployment</username>
            <password>deployment123</password>
        </server>
    </servers>
    <mirrors>
    <mirror>
        <id>mirror1</id>
        <mirrorOf>*</mirrorOf>
        <name>Maven2 official repo</name>
        <url>http://repo.maven.apache.org/maven2</url>
    </mirror>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/repository/maven-public/</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>

And of course I've double checked the repository directory in .m2 . The ojdbc6.jar is there.

So what's wrong with my setup?

Upvotes: 2

Views: 6480

Answers (3)

Sunny
Sunny

Reputation: 99

Use the following dependency:

<dependency>
    <groupId>com.oracle.ojdbc</groupId>
    <artifactId>ojdbc8</artifactId>
    <version>19.3.0.0</version>
</dependency>

Upvotes: 0

rawdog
rawdog

Reputation: 732

I had the same issue with ojdbc8.jar. The build failed with this dependency in my pom.xml.

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc8</artifactId>
    <version>19.3</version>
</dependency>

I copied the ojdbc8.jar to the Jenkins maven repository. After renaming it to ojdbc8-19.3.jar my build was successful.

Perhaps this helps someone else.

Upvotes: 0

mbruns42
mbruns42

Reputation: 448

You might want to check what Jenkins uses as its local repository.

Go to Jenkins verwalten (Manage Jenkins)

Under Maven-Projekt-Konfiguration (Maven project configuration), there should be a setting where the .m2 repository for Jenkins is located.

If that was not the same repository you were using locally, that would explain your error.

Edit: There is also an option for each job whether or not to use a "private repository". That repository will be specific to that job and not share artifacts with any other.

Upvotes: 2

Related Questions