What is the difference between deploying an artifact into Artifactory with 'mvn deploy' command and with Artifactory UI? - maven

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.

Related

Running Jenkins Job using only the local repository

I have a Spring boot project on my local machine and I am using personal dependencies in the project. When I run mvn clean package on the windows terminal it works but when I use mvn clean package in the Jenkins Job it does try to download dependencies in the remote repository. My question is how to force Jenkins to use my local repository without looking the remote one.
You should able to use maven option mvn -o or mvn -llr.
But that assumes ~/ is the same user Jenkins agent ia running on.
Your better bet is to use mvn install:install-file to install the jars locally.
You can set up your job to do a curl.or wget step to retrieve the files from "somewhere", then have your pom call a pom which installs the jars locally from workapce to repo, then does your build.
That makes your job portable and still pulls the rest of OSS jars from Central, without needed an intermediary remote.

Maven deploy current artifact in target folder as it is

For a web application we have a Jenkins pipeline with these steps:
maven build of the back-end (mvn clean install)
npm build of the front-end (npm run build)
update the back-end .jar file including inside the front-end dist folder (jar -uf ...)
deploy that jar file into our development environment (docker container on OpenShift)
This works very nicely for the deployment. The question now is how to keep these artifacts in our repository (Artifactory). If we use the mvn deploy command in step 1, the artifact we store in our repository will be the jar file without the front-end. What I would like is after step 3 make a call to maven that deploys the jar file in the /target folder as it is without modifying it.
I've seen this other question, but like this I would need to specify many things as version, groupId... what from Jenkins could be difficult and also all this information is already defined inside the pom.xml file.
Would it be possible to call maven to use the already contained configuration and just perform the upload to Artifactory step?
You can probably just call
mvn deploy:deploy
in the end.

Getting Artifactory Plugin to work with Jenkins and Maven

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.

Maven - Install an artifact to the Nexus repository

I have a problem currently when i run the command mvn install, the artifact is installed in my local repository (i.e. in %HOME/.m2 folder) but not in the Nexus repository.
I know with Nexus i can add an artifact manually using the GUI but is there a way to do install the artifact as part of the mvn command?
What you're seeing is normal behavior in the standard maven lifecycle. The install phase is only supposed to install the artifact locally. You need to run deploy, which comes after install. That's when maven uploads artifacts to a remote repository. The remote repo for deployment is configured in the distribution management section of the pom.

Share Maven Dependencies with team members using Mercurial

I want to share all the External Jars currently being managed by MAVEN with my other team members. I am using Mercurial as my SCM and i am trying to figure what is the easiest way to commit my entire project (include libs) to a repository so that my team members can clone and get running without severe eclipse configuration?
Maven is there in order to help you retrieving libraries. So that, all you have to do is to commit all your files including the pom.xml (.hg should contains everything in target, and other unrelevant files)
Then your project members can pull the sources and run mvn eclipse:eclipse (see eclipse & maven.
And finally import the project in Eclipse.
That was is they need sources...
If they only need the jars, you must put in your infrastructure a company repo that will handle your deployment using mvn deploy. Some information there maven repo::Intro, take special care at the wagon you could use (ftp, ...)
This way, when you're done with your devel and you have pushed your code, you just have to deploy the jar on your repo.
Doing so, your project member'll have to run mvn -U eclipse:eclipse or any goal to update their local repository with your lastest deployed version.

Resources