Upload Jenkins build file .war to Nexus Repository remotely - java

I have Jenkins setup with Maven as a build tool. Java project is pulled from SVN and it is built using Maven (all inside Jenkins). Once the project is built I get project.war package file which I need to be uploaded to Nexus Repository.
Whats the simplest way to do that?
I tried tweaking/modifying my existing settings.xml and pom.xml, but no luck. Nothing is happening.
I want the .war file to be uploaded to Nexus Repository which I configured on other box.

You can use the Nexus Maven Plugin for your purpose. And in your Jenkins script, just run:
mvn clean deploy
As it is described in the documentation.

I tried mvn deploy, mvn clean deploy but neither work.. "mvn" dont work (May be I need to set environment variable or something.. help me ! with that too ! :))
Somehow it worked fine now. I am using the Goal as : clean deploy it worked for me. Also, when I used below in pom.xml file :-
release and then snapshot
It didn't worked.
However, I have created new repo in nexus and provided its path. It worked fine. Jenkins was able to upload my .war file to Nexus repo.
Now Next I have to do is,
As many build my jenkin produces and push to Nexus. Nexus should version it for me.. Any idea would be really appreciated

Related

Maven Dependencies are not installing in eclipse

I am using the maven embedded eclipse.
Tried :
Deleting the whole m2 repository.
Maven->Update Project.
Run as -> Maven Build
User settings file does not exist(Please don't tell me it has to something with this file)
settings.Xml file
This file is only required if you are using a proxy and i am not
I have every dependency present in pom.xml file of my project but still eclipse is not able to import all these dependencies in the project
I have attached the photo below. Please help me to resolve my issue
mvn dependency:tree
Maven Dependencies
POM.xml file
List of dependency present in pom file of my project
None of the methods mentioned above worked so please help me to solve this issue.
Is there anything related to maven or eclipse version ?
When you execute mvn dependency:tree result shows an error related to "i cannot obtain some jar", it may be due to private reporitory.
If you are working with private repository, make sure you configure access in $HOME/.m2/settings.xml
On another hand I see you are working with snapshots. If you are trying to bind projects you have in your local host machine, ensure you are executing mvn install (or better mvn source:jar install) sucessfully and your system's maven is pointing the same .m2 path that refers Eclipse maven plugin
It seems using the Spring framework Maven repository via HTTP instead of HTTPS causing this issue.
In your pom.xml file replace http://maven.springframework.org with https://maven.springframework.org.

POM file Uploaded by Artifactory Jenkins plugin won't resolve in Maven builds

I am building a jar in Jenkins and uploading it to an Artifactory repository. I've verified the jar, the pom, and the hash files are present in the repository. When I try to build a project on my machine that has a dependency on the jar, it downloads the jar correctly but then I get a POM file is missing message and the maven build fails. I don't see any rhyme or reason why this should fail, I've done an Artifactory trace on the jar and the pom in Chrome and Firefox and the response says that it found the files. So I don't understand what could bve causing the issue? We were running Artifactory 5.2.1 and upgraded over the weekend to 5.5.1, but it hasn't changed anything. What should I be looking at?
Thanks.
EDIT: This question is about to be moot. Discussions are in progress about setting up a generic maven repository and avoiding the use of Artifactory altogether, since it won't do what is needed.
First, make sure your groupId and artifactId are correct. I've lost a lot of time thinking it's a maven problem when it's really just that I reversed a couple letters in a long groupId.
Next, have you tried 'forcing' maven to bypass its local cache? Try running mvn -U <your tasks>
If that doesn't work, try deleting the ~/.m2/repository/path/to/the/artifact/with/the/missing/pom and use mvn -U again
OK, problem solved. Turned out to be a Maven problem, not an Artifactory problem. Our maven settings contain a proxy setting so we can pull down jar from Maven Central - problem was, our company url was incorrectly configured in the nonProxyHosts tag, was set to domain.org, instead of *.domain.org, so it was trying to retrieve the maven artifact through the proxy instead of going directly to the Artifactory server. My apologies to the Artifactory devs for blaming the problem on Artifactory.

Maven trying to download a local dependency

I'm working on an API that depends on a small library I created in my project. In IntelliJ IDEA, it looks like :
PROJECT : myProject
MODULE : mySimpleAPI (maven project + spring boot application)
MODULE : mySmallLib (maven project)
I just added mySmallLib in mySpringAPI's dependencies.
But when I execute the spring-boot:run command, it tried to download the dependency from spring repositories. I tried in offline mode, but it also didn't work. How can I tell to maven that the dependency is already in the project and it doesn't need to download it ?
run mvn clean install on "mySmallLib" project first. This will install the jar in your local maven repo. Then you can perform mvn spring-boot:run on "mySimpleAPI" project.
Seems your code/library is not updating automatically. So you will need to update them manually.
Go to each sub module of your project and open pom.xml. now right click on the file and click on clean install.
Try running your application again, and it should work. Let me know if it doesn't.

what does Maven -> Update Project... exactly?

I am getting really frustrated about this one:
I am using an maven project, using jdbc with eclipselink. mvn install works as intended. Until I have to change the PW in the persistence.xml. When I do an mvn clean and afterwards mvn install the project is broken and the wrong (old) persistence.xml is still in use. In eclipse I have to do maven -> update project (using m2e addon) and mvn install works suddenly again.
Now my problem: On the deployment server I am using command line scripting and I found no mvn XYZ equivalent for the m2e functionality...
Is there some equivalent?
Explicit scenario:
I am developing on my local machine (osx/win7) in an maven project imported in eclipse. I have a JPA Persistence interface which encapsulate the database connection which is realized via eclipselink. I can deploy locally (mvn install) but after I run mvn clean and change the password in persistence.xml mvn install isn't possible anymore. I just get classDefNotFound Persistor in the tests because it static initialize the EntityManager which can't connect cause of the new persistence.xml -- or at least it's my opinion, because the stacktrace is not really helpful. But, after maven -> update project... in eclipse on the project, mvn install works again and the new password is taken (tests run!).
When I want to deploy the project on a remote machine (debian, commandline) I can't ´mvn install` the pulled project, cause after I changed the password in persistence.xml for deployment, it's again the wrong persistence.xml or at least some cached used.
I hope that make it a bit more clear.
SOLUTION:
Make sure persistence.xml is placed in src/main/resources/META-INF and not elsewhere. m2e catches persistence.xml from wrong places (in my case, src/main/java/META-INF). So it was basically just a wrong project structure.
Looks like you can use mvn eclipse:clean eclipse:eclipse to regenerate the eclipse project files -- hope that sorts you.
maven update project from eclipse is different because it will generate a Maven Dependencies class path container
mvn eclipse:eclipse generates a Referenced Library Container.

How to stop eclipse to redownload the plugin from repository for a maven project

I am importing an existing project into my eclipse workspace. I am using Maven 2.2.0, and Eclipse Juno. I could build project successfully using mvn command prompt.
But unable to import the project as eclipse could not build the project.Eclipse is trying to again download from repository. What If we stop eclipse to download the resources again from repository.
I thought I would add Windows--->Preferences-->Maven--Archetype--Add local catalog
I understood that we have ~/.m2/archetype-catalog.xml catalogu file. But to my surprise I cannot find it.
Please suggest me if I am proceeding with correct way or not.
If its correct way, how do I set local archetype.
Please share your thoughts.
Thanks In Advance.
You need to install the mvn plugin and import the mvn project as such. Alternatively, you can eclipsify the mvn project using the goal eclipse:eclipse (with the mvn command line).
In mvn itself you could set the pluginRepo to updatePolicy NEVER temporarily, if you still have issues with Eclipse. I think Eclipse uses the same settings for importing mvn projects.
http://maven.apache.org/settings.html
I personally never was happy with Eclipse's mvn integration. Have you tried IntelliJ?

Categories

Resources