dreemoutloud
dreemoutloud

Reputation: 1

Maven - jenkins pipeline not using pom

I have a problem running a maven deploy through Jenkins. When run locally, the correct URL is contacted, but via Jenkins(in the middle of a pipeline), it does not. It also states that it is using a different plugin to do so. How do I get Jenkins to contact MY_URL like my command line does?

(I've cleaned up the output a bit)

Running the following through the command line gives me:

mvn clean deploy -DaltDeploymentRepository=nexus::default::https://MY_URL/ -DskipTests -P nexus -X -s ./settings.xml

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project MY_PROJECT: Failed to deploy artifacts: Could not transfer artifact from/to nexus (https://MY_URL): Failed to transfer file 20200217.092316-15.jar with status code 401 -> [Help 1]

This is what I want (I'm waiting on credentials - but it is hitting the correct URL)

Running via Jenkins gives me: [ERROR] Failed to execute goal org.sonatype.plugins:nexus-staging-maven-plugin:1.5.1:deploy (default-deploy) on project : Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]

I have done a "diff" on the pom files in use by jenkins and locally and they are identical; likewise with the settings.xml I suspect this is a plugin problem but do not know where to go with it.

Items I have tried:

Upvotes: 0

Views: 805

Answers (1)

J Fabian Meier
J Fabian Meier

Reputation: 35903

Your Jenkins runs the org.sonatype.plugins:nexus-staging-maven-plugin:1.5.1:deploy goal.

It is either specified in the POM or given on command line. So first of all, check whether the nexus-staging-maven-plugin is configured in your POM or in one of the parent POMs. If so, check if it run conditionally or is part of a profile.

Secondly, look at the command line call in Jenkins and see if it is exactly the same as the one you ran locally.

The third possibility is that you run a Jenkins plugin from Sonatype that implicitly tries to deploy artifacts. So watch out for Sonatype specific Jenkins plugins.

One of the three strategies should lead to the source of the problem.

Upvotes: 1

Related Questions