vadipp
vadipp

Reputation: 948

How to specify an internal company Maven repo for a Jenkins job to use?

I'm trying to setup a Maven2 job in Jenkins. I've got such lines in my pom.xml:

<distributionManagement>
  <repository>
    <id>releases</id>
    <name>Releases</name>
    <url>http://nexus.example.com:8081/nexus/content/repositories/releases</url>
  </repository>
  ...
</distributionManagement>

I get this error when trying to build the job:

...
Downloading: http://repo1.maven.org/maven2/.../.../.../....jar
[INFO] Unable to find resource 'resource id goes here' in repository central (http://repo1.maven.org/maven2)
...
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

Missing:
...Here goes the list of missing dependencies.

I know for sure that the required artifacts do exist in nexus.example.com repository, because I can do an mvn compile on my workstation and they will be downloaded OK.

But Jenkins for some reason does not even try to download the artifacts from local repo, ignoring the specification in the pom.xml.

Any ideas what can I try?

Upvotes: 0

Views: 2213

Answers (1)

Raghuram
Raghuram

Reputation: 52635

You can resolve this error in two ways.

One, move the <repositories> section out of <distributionManagement>. <distributionManagement> section is to indicate where you want to deploy your artifacts.

Specify the <repositories> section in the settings.xml of the username jenkins is running under. This is recommended, since this will apply for all the projects that you would be building.

Upvotes: 1

Related Questions