How do you get maven child projects to build in Jenkins when using CI Friendly versions? - maven

I am using CI Friendly versioning in my Parent-Child Maven project. I can't get the child to build on the Jenkins server. It builds fine on my server. I am getting the "Failed to parse POMs" error saying it can't find "myProj-parent:pom:${revision}" in nexus. I am using the Maven Flatten Plugin and as I said it works when I run Maven from my server. But for some reason in Jenkins it is not resolving.
The "revision" is set in the properties section of the parent POM.
Any hints?

We have the same problem when we do a sparse checkout of the child module only.
We solved it by adding a sparse checkout of all pom.xml files.
I hope this will help you.

If you're using the Jenkins maven-plugin, the failure may be due to an old unresolved bug. A workaround from the JIRA conversation is to use the pipeline-maven-plugin (withMaven step).
The pipeline-maven-plugin exposes a similar bug in Maven that was fixed in version 3.8.5. My build works using the pipeline-maven-plugin after upgrading Maven on the Jenkins server.

Related

AEM Mocks missing artifact for latest version

I have added the latest version of AEM Mocks (2.7.2) as a Maven dependency in my AEM project. When I try to build my project, I get an error saying that this artifact cannot be found: com.day.commons:day-commons-gfx:jar:2.1.28. So I looked online, found it and added it as a dependency. But now I get the same error when trying to build. Does this artifact still exist? When trying various recent versions of AEM Mocks, I found that they all depend on this missing artifact.
For now, I downgraded to version 2.3.0, which works fine without that artifact but I would like to use the most recent version if possible.
Can anyone please help? Thanks!
This artifact is defined as a workaround, it is explained here in comment:
https://github.com/wcm-io/wcm-io-testing/blob/develop/aem-mock/core/pom.xml#L254:
Workaround for AEM 6.5: The new uber-jar does no longer contain the package com.day.imageio.plugins
It works without any issues for me, so I would check if you have correctly configured Maven repositories. To do it, in your Maven project root type:
mvn help:evaluate
and then:
${project.repositories}
It should list your project effective repositories. Ensure that there is Central Repository (https://repo.maven.apache.org/maven2/) listed. If it is there, then maybe your corporate network cuts requests to external repositories or it was temporarily down.

how to force mvn redownload snapshot

I got a maven project (myApp) depending on another maven project in snapshot version.
like:
<dependency>
<groupId>org.group.dep</groupId>
<artifactId>arty</artifactId>
<version>12.1.4-SNAPSHOT</version>
</dependency>
But I got a problem with this after the "arty" got an update without changing the version (I know that would be the cleanest solution).
I build the myApp local and got still the old version of the "arty" dependency.
I verified tow option working for me (and a college):
1) Manual cleaning of the local repository: navigating to my .m2/repo/org/group/dep/arty and deleted all folders inside. After rebuilding the myApp local it was working fine - arty was downloaded form the artifactory.company.com again with the updated content.
2) Local building of the arty package so it got updated in the local repository. After rebuilding the myApp local it was working fine.
But I got similar problem on the Jenkins:
I got a Jenkins job just building org.group.myApp without building before org.group.dep.arty. It failed for the missing changes form "arty".
What can I do now to solve my problem there?
I can not rely on first building org.group.dep.arty as I can not be sure for Jenkins to run both jobs on the same host using same local repository (I don't want to change that).
Somehow the myApp-Jobs was failing after I manually cleared on that Jenkins node the org.group.dep.arty in the repository and running than the myApp-job (was somehow not downloading the package).
I finally found the mvn -u but as I tried this I was as well disappointed.
I tried different maven versions on that jenkins and got the same result.
Is there no way to force the update of the snapshot versions?
Is this "another project" is a part of the same multi-module project?
If so you can build your project with --also-make options so that maven will effectively rebuild your module and all of its dependencies
If its an entirely different project, use mvn -U to forcefully download all the snapshot dependencies of your project.
If there is a particular issue with one concrete dependency consider using mvn dependency:get. This get goal of maven-dependency-plugin downloads one specific artifact from the remote repository
Here is a link to the plugin documentation
The simplest solution to redownload -SNAPSHOT is by using the command line option: -U or as long option --update-snapshots
Furthermore your project sounds like the need for a multi module build which prevents such issues. Or you might need to define those Jobs depending on each other (There is an option to build if a SNAPSHOT has been updated in Jenkins).

How to setup Travis-CI to consume dependencies from oss.sonatype.org

I currently have a travis-ci setup that runs a build out of a github repository. Previously I had no need for snapshots in oss.sonatype.org but now I do. I'm getting an error saying that the dependency can't be found meaning that travis-ci I assume does not use it as the default maven repo. How can I tell travis to use oss.sonatype.org as well as its default repo's setup?
edit 1: Upon further investigation i found that travis is apparently setup to use central and sonatype mirrors so i'm not sure what's going on at all.
https://travis-ci.org/FINRAOS/herd/builds/298071150

How to configure maven multi module project and FindBugs?

I have a multi module maven project ('assembler'), and I would like to add a FindBugs phase.
The problem is that some of the projects are not able to build stand alone since have dependencies on other projects... however when I invoke mvn package from the 'assembler' project - it works fine and all inner dependencies are resolved.
The problem is that when mvn findbugs:findbugs command is executed, those inner dependencies are not resolved, and maven complains.
Searching Google, I found a way to make it work, using mvn install, but I do not like this approach since eventually this should be used in CI with Jenkins and I do not want to rely on local maven repo on the build server.
Will appreciate hearing your ideas.
Thanks.
Don't be afraid of mvn install, it is your friend. What you need is to set up a centralized Maven repository (such as Nexus or Artifactory) or rent one (such as Bintray) to which you deploy your Maven artifacts to.
Jenkins or any other decent CI engine can do the actual deploying for you, either natively or through Maven. Once deployed, other users - Jenkins included - will be able to resolve their dependencies and you will be able to run FindBugs, PMD, JaCoco, host Javadoc or pretty much anything you want.
Side-note: Don't get confused by the term deploy as most people new to Maven usually get. In context of Maven, it has absolutely nothing to with your target environment. It simply means that an artifact is pushed out to a remote repository and nothing else.

Clean my maven local repository

i am trying to find a automatic way to clean my Maven local repository.
i am already tried using the purge plugin but he didn't work as i expected (was no consistent). then i tried the remove-project-artifact plugin. This plugin work as i expected, but then i had new problem, i have more then one Maven project that use the same local repository, so when a few build run in the same time (only one of the build operator the remove-project-artifact plugin), some of the build are failing because of this plugin.
so my question is if someone had the same problem and managed to solve it?

Resources