2

On my windows machine: I have setup jenkins CI to automatically create build.

But every time build is failing because of the third party ojdbc7.jar file.

[ERROR] Failed to execute goal on project abc-cc-onboarding-repository: Could not resolve dependencies for project com.abc.cc:abc-cc-onboarding-repository:jar:1.0-SNAPSHOT: Could not find artifact com.oracle:ojdbc7:jar:12.1.0.1.0 in central (https://repo.maven.apache.org/maven2) -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR]

When I manually build using: mvn -U clean build, everything works fine. because I have manually installed ojdbc7.jar in the local repository (.m2)

Something is wrong with the Jenkins integration with maven.

Can anybody suggest on this?

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
Sahil Verma
  • 131
  • 3
  • 12
  • If you use a Maven remote repository like Nexus, you can upload this dependency into it. Like said in http://blog.sonatype.com/2008/11/adding-a-jar-to-a-maven-repository-with-sonatype-nexus/ – Guillaume Husta Nov 28 '17 at 13:20
  • Thank you for your prompt reply. @GuillaumeHusta: I have jar in my local repo, why should i install it in some other repo, because it will make my app dependent on their repo. – Sahil Verma Nov 28 '17 at 13:21
  • Maybe the local repo of Jenkins is not the same as yours ? You can redefine `localRepository` in ~/.m2/settings.xml (http://maven.apache.org/ref/3.5.2/maven-settings/settings.html) – Guillaume Husta Nov 28 '17 at 13:24
  • @GuillaumeHusta: then it should also throw error while building app using cmd: mvn clean package I am new to jenkins, if you can help me trace out where i have to change maven configuration in jenkins. – Sahil Verma Nov 28 '17 at 13:27
  • Possible duplicate of [Jenkins : Add custom jar in maven project](https://stackoverflow.com/questions/44583836/jenkins-add-custom-jar-in-maven-project) – Joe Nov 28 '17 at 13:30
  • Maybe try to check Maven settings with `mvn help:effective-settings` on both your local CLI and on Jenkins (http://maven.apache.org/plugins/maven-help-plugin/effective-settings-mojo.html). – Guillaume Husta Nov 28 '17 at 13:41
  • @Joe: I have already installed that jar in my local. – Sahil Verma Nov 28 '17 at 13:57
  • @GuillaumeHusta: on jenkins, how can i check settings ? – Sahil Verma Nov 28 '17 at 13:58
  • Create a job (maven) which just executes this command (help:effective-settings) – Guillaume Husta Nov 28 '17 at 14:06
  • Are you sure **your** local repository is the same as the one used by the Jenkins process (which I assume and hope is running as a different user). – Mark Rotteveel Nov 30 '17 at 18:21

3 Answers3

3

Something is wrong with the Jenkins integration with maven.

No. That's not the problem. Jenkins integration with Maven works just fine.

The problem is that ojdbc7.jar is not in the Maven Central repo ... which is the default place that Maven looks. (Or at least, it is not in Maven Central not with those artifact "coordinates". There are some ojdbc artifacts with different coordinates. YMMV.)

The real problem is that Oracle don't want you to download Oracle JARs from Maven Central. Oracle want you to download from their Maven repo instead.

One solution is to do what you have been doing. Simply add the artifact to your local repo (or Jenkins' local repo for the project). But you are not happy with that.

The other solution is to configure the remote repos that Maven uses.

Here is a page that explains how to configure (stand alone) Maven to include the Oracle repo:

For the Jenkins case, you need to configure the settings that the Jenkins server uses:

This lists various ways of doing this.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • i was not aware about the fact that jenkins creates separate repo for the different project. after digging in to jenkins internal, i found the answer. Thank you – Sahil Verma Nov 28 '17 at 14:21
0

SOLUTION THAT WORKED FOR ME:

What i found after the analysis and it resolved my problem, hope it will help somebody like me.

Actually jenkins creates a separate repository for separate projects. like if i have 10 project in my jenkins workspace then it creates 10 repository one for each project (inside the project on top level we can see that).

so now i installed manually ojdbc7.jar inside my jenkins project repo and it solved my problem.

Sahil Verma
  • 131
  • 3
  • 12
0

The above error occurs mostly when Jenkins is unable to download the oracle jar.

To sort the above issue

  1. Create the settings.xml and settings-security.xml files in Jenkins through the "Managed files" in the administration home. To do that follow this link - https://wiki.jenkins.io/display/JENKINS/Config+File+Provider+Plugin#ConfigFileProviderPlugin-Howitworks NB: Ensure to put in your Oracle credentials in these two files. To do that follow this link - https://docs.oracle.com/middleware/1213/core/MAVEN/config_maven_repo.htm#MAVEN9017
  2. In your jenkins project under configurations in Build Environments include this files under the option Provide Configuration files. As shown below: enter image description here
  3. Once done build it and it should work.
Amimo Benja
  • 505
  • 5
  • 8