I'm having an issue where Maven is not passing the settings to the deploy phase when I use the release plugin. I have my settings.xml file in the same folder as my pom.xml. When I run the following command it deploys successfully to the Maven repository.
mvn deploy -s settings.xml
However when I run this command, it fails saying that it doesn't have permissions to deploy to the repository.
mvn release:perform -B -s settings.xml
Here is the error message:
[INFO] [INFO] Error deploying artifact: Failed to transfer file: http://mavenrepo/groupId/artifactId/versionId/artifactId-versionId.pom. Return code is: 401
The only thing I can think that is causing the second to fail is that the release plugin doesn't pass the settings down to the deploy phase. How do I get this to work?
I used to have the MAVEN_OPTS environment variable set to specify my settings.xml file, but since this will run on from TeamCity, that is no longer an option.
I found a bug in the codehaus Jira for this same issue here. It was fixed in maven-release-plugin 2.2.2. As soon as I changed the version number in my pom.xml, it worked fine.
Related
I usually use mvn versions:use-latest-versions command to update my dependencies to the latest ones which other teams have been deployed to our free Jfrog's Artifactory server on our local address : http://192.168.100.243:8082/artifactory/X_Douran/.
My problem is when I deploy an artifact (a jar file) with Artifactory UI or with curl (using Jfrog's Rest Api), the command mvn versions:use-latest-versions doesn't work correctly and do not update my pom but when I run mvn clean deploy on my source code of my dependent project then running mvn versions:use-latest-versions on my final project it works correctly and do update my dependency in my pom.
So I want to know what is the different between deploying via Artifactory UI and deploying via mvn clean deploy ?
You always need to deploy the POM along the JAR, otherwise Maven will not work correctly with these dependencies. Furthermore, you need to make sure that the metadata files are updated. I am not sure that Artifactory does this if you deploy using curl or the UI.
Deploying your own JARs regularly through the UI is not recommended. You should build them on a build server (like Jenkins) and then automatically deploy them to Artifactory.
Changing JAR files "by hand" should be forbidden.
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:
mvn clean beforehand
reinstalling mvn
echoing the settings.xml and pom.xml into the jenkins output
Specifying altDeploymentRepository in the settings.xml and/or
commandline
Specifying altDeploymentRepository using the -Dproperties= flag
Combinations of altDeploymentRepository, altDeploymentDirectory,
altSnapshotDeploymentRepository
Endless research
Hopeful reruns
Banging head on desk
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.
I am trying to build a maven project in Jenkins with Build Profile ID of pom.xml. But Jenkins is only building with dev profile and not catching any of other profiles. with the same pom.xml.
I've tried building on command prompt and it's working fine, I just cannot do it in Jenkins.
I am having similar issue running maven 3.3.9 from Jenkins ver. 2.138.
So far, with time consuming trial and error, I have found that Jenkins does not tolerate a space between the -P and the profile name AND it can only handle a single profile. So you should be able to get something like this to work:
mvn groupId:artifactId:goal -Pprofile-1-only
how did you set-up your Jenkins to run the command?
Profiles should b specified using the -P option:
mvn groupId:artifactId:goal -P profile-1,profile-2
http://maven.apache.org/guides/introduction/introduction-to-profiles.html
My guess is that in your Jenkins config (build steps), you have not specified anything, or you provide the wrong profile.
Could you try and let us know?
I am trying to setup Maven(3.2.5) on linux with nexus repo for non Java artifacts. I was going through all the SO questions, and got to know that with Maven command line, one can publish artifacts to repo without POM for non java artifacts.
When I am running maven deploy file command to push non java artifacts(zip file) to nexus repo, and it throws the following error
"Failed to find plugin prefix deploy". I
Here is the pluginGroup tag from my settings.xml, which is under conf dir. How do I get rid of this failed to find plugin error.
Thanks for your time!
<pluginGroups>
<pluginGroup>org.apache.maven.plugins</pluginGroup>
</pluginGroups>
This plugin group tag is not required in setting.xml file. I was not able to download plugin from maven due to firewall issue.
after setting up proxy, I was able to use maven build successfully.
I have a large Maven project in Jenkins. It consists of a parent project, and about a dozen local projects. Using Jenkins, I am able to do mvndeploy` and for the build to successfully deploy to my Artifactory repository.
However, I can't seem to get the Jenkin's Artifactory plugin to work itself to work.
My Artifactory setting in Jenkins:
And here's the setting for our job:
When using the Jenkins Artifactory Plugin you should execute mvn install instead of mvn deploy.
This is because the plugin collects the published artifacts from Maven and when executing mvn deploy directly you are kind of by-passing it's behavior.
Use Build Step "Invoke Artifactory Maven 3" when working with Artifactory plugin. And most preferably use goals "clean install"
I had the same problem and resolved by adding details under Build Environment -> Generic-Artifactory Integration as shown in below image
Published Artifacts now started uploading into desired location in artifactory.