[HAP-236] Artifact resolution does not work for POMs defined as a parent of a POM Created: 08/Sep/11  Updated: 26/Sep/15  Resolved: 15/Oct/13

Status: Resolved
Project: Jenkins Artifactory Plug-in
Component/s: Common, Maven3
Affects Version/s: 2.0.4
Fix Version/s: 2.2.0

Type: Bug Priority: Critical
Reporter: Umesh Desai Assignee: Shay Yaakov (Inactive)
Resolution: Fixed Votes: 3
Labels: None

Jenkins 1.428
Artifactory Pro
Maven 3.0.3


I have a corporate POM, which is defined as a parent for all Maven projects. As such, the corporate pom is not available on the source path, cannot be resolved through relativePath, and must be resolved through a Maven repository.

Running mvn clean install on the cmd line with an appropriate repository setup in settings.xml, Maven is successfully able to resolve the corporate POM from an Artifactory repository.

When running in Jenkins, and having enabled 'Resolve artifacts from Artifactory' for the project, the build fails to override artifact resolution for the corporate POM but does override artifact resolution for anything in the dependencies section.

Here is a snippet of the log when the build tries to resolve the corporate POM

Parsing POMs
Downloaded artifact http://host:8080/artifactory/sample-public//com/company/root/pom/1.0.1/pom-1.0.1.pom
[Sample Project] $ /apps/sw/oracle/jrockit-x64/bin/java -Dm3plugin.lib=/apps/services/hudson-home/workspace/artifactory-plugin/2.0.4 -cp /apps/services/hudson-home/maven3-agent.jar:/apps/sw/apache/maven/maven3/boot/plexus-classworlds-2.4.jar org.jvnet.hudson.maven3.agent.Maven3Main /apps/sw/apache/maven/maven3 /apps/services/hudson-home/slave.jar /apps/services/hudson-home/maven3-interceptor.jar 50937

and here is a snippet from a little further down the log where artifact resolution does work correctly

[INFO] Building Sample Project Parent 1.0.0-S6-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[DEBUG] Intercepted artifact downloading event: ARTIFACT_DOWNLOADING com.google.code.maven-svn-revision-number-plugin:maven-svn-revision-number-plugin:pom:1.6 @ mirrorId (http://host:8080/artifactory/sample-public/, releases)
[DEBUG] Enforcing repository URL: http://host:8080/artifactory/repo for event: ARTIFACT_DOWNLOADING com.google.code.maven-svn-revision-number-plugin:maven-svn-revision-number-plugin:pom:1.6 @ mirrorId (http://host:8080/artifactory/sample-public/, releases)
[DEBUG] Enforcing repository authentication: deployer for event: ARTIFACT_DOWNLOADING com.google.code.maven-svn-revision-number-plugin:maven-svn-revision-number-plugin:pom:1.6 @ mirrorId (http://host:8080/artifactory/repo, releases)

In the snippet above, sample-public is defined as a mirrorOf * in the settings.xml and repo is defined as the override repository for artifact resolution. The first snippet resolves the parent POM through sample-public, when it should resolve it through repo as the resolution repository should be overridden.

Comment by Yossi Shaul [ 11/Oct/11 ]

The failure occurs when Jenkins itself tries to parse the pom files before the build is started. This process is not controlled by the plugin as it happens before the plugin is executed and outside of the Maven process.

In your specific case you'll have to add the repository containing the parent pom to the settings.xml for Jenkins to find it.

Comment by Yoav Landman [ 14/Oct/11 ]

Unless there's additional input on this we'll resolve the issue, since the error is unrelated to the Artifactory plugin.

Comment by Yoav Landman [ 19/Oct/11 ]

Not an Artifactory plugin issue

Comment by nicolas De loof [ 17/May/13 ]

As the pom-parsing phase is executed on the build slave, local repository will be populated by artifacts that aren't under artifactory control, and some may not be resolved (parent in this case). This makes the "resolve from artifactory" jenkins option useless.

Please consider re-opening this issue, and add support for artifactory in the pom-parser, maybe need to introduce the adequate extension point in jenkins if required.

Comment by Yoav Landman [ 06/Aug/13 ]

"Cannot reproduce" means this is not reproducible within the context of the Artifactory plugin as a maven build interceptor, which is what the plugin is doing: when a maven build runs we force resolution by correctly taking over the maven resolution process. Perhaps a better resolution would be "not a bug". Problem is, preliminary pom scanning resolution is beyond our reach.
I believe there has been work initiated with KK to resolve this and hook-in to this early resolution process, so we need to follow up with that.

Comment by nicolas De loof [ 07/Aug/13 ]

I don't agree with labelling. not "cannot reproduce" nor "not a bug", maybe "won't fix" would better express you don't consider this use case.

If artifactory interceptor can't contribute the POM parsing phase it's mostly useless, as you can't run a Jenkins maven job :'(

[Wearing my maven/jenkins contributor hat]
Jenkins is using maven 3.x in embedded mode during this process, so this sounds feasible to introduce the necessary extension point in jenkins so plugin can inject it's interceptor.

Comment by Yoav Landman [ 07/Aug/13 ]

@nicolas Bear in mind this only affects projects that need to resolve an external parent pom. We can see why it can be problematic in a cloud environment where you cannot use the workaround of augmenting the settings.
In any case, there is already extension point for that and we will look into it.

Comment by Patrick Renaud [ 20/Sep/13 ]

What are the plans with a fix for this? I mean, it effectively makes the Resolve artifacts from Artifactory useless if your top POM includes a refence to an external parent. And of course, we happen to fall in that situation often....

Meanwhile, what do I tell our users? That they need to craft their own settings.xml??

Comment by Luca Menegus [ 26/Sep/15 ]

A stupid workaround I found:

add a pre build step of the Invoke top level maven target type to jenkins.
Specify a custom maven setting file in which you declare a mirror where the parent pom can be found.
This step gets executed before jenkins tries to parse the pom so you have a chance to force downloading the pom.

From jenkins logs:
[workspace] $ /opt/maven/apache-maven-3.3.3/bin/mvn -f pom.xml -s /var/lib/jenkins/.m2/settings-plus-snapshots.xml -gs /var/lib/jenkins/.m2/settings-plus-snapshots.xml clean

Artifactoy plugin will be used in the 'normal' build step.

That said this issue is annoying...

Generated at Mon Jun 01 19:27:47 UTC 2020 using Jira 8.5.3#805003-sha1:b4933e02eaff29a49114274fe59e1f99d9d963d7.