0

I need to build a Java project on Maven. I am working on a multi-module Maven project that's built on the Jenkins Pipeline in the Nexus repository. I have a few libraries that are not available on the Nexus repository. I can't manually upload the libraries. I am building this project on a pipeline.

What I did:

I created a folder named jars in the project root of the Git hub repository and manually put all the jar files that are not available on Nexus. In the dependency, I referenced all these local jars as in the dependency parameters.

In the repositories, I gave the URL of the git hub repo of the jar folder. The Jenkins were not able to pick the libraries. I am getting the following error: dependency: dependency version - Build Error - Could not build for non-released dependencies and I am getting an error for all the jars that are in the jars folder. I tried putting the jars folder in src/main/resources but still getting the same error.

How can I reference this jar folder so that the Jenkins Pipeline can take it? I don't have control over the Jenkins / Scripts that are involved. I am a developer just building it on the Pipeline.

P.S: I don't have access to the internet at my company to post the POM or Build Failure errors.

Adding more details:

It's built on the Pipeline. There are two repositories: Nexus 2 and Nexus 3. The particular libraries are not available on Nexus 3 and pipeline takes the build only on Nexus 3.

We have raised a request to upload those libraries but it's not going to happen anytime soon. The Jenkins Pipelines takes it's files from the Github repository and builds the Java project using Maven. I don't have control to a pipeline or any of the scripts in Jenkins.

We downloaded all the libraries that are not available and put that in a folder in git hub. There are 4 cycles in the Pipeline. Github Cycle / Jenkins Cycle / Deployment Cycle / Release Cycle.

Github Cycle: In this cycle, it follows three stages. It takes the code from the code, builds it. It builds the snapshot and uploads it to Nexus repo. In these 2 stages, it was able to successfully build by taking the code from the GitHub and builds it and artifact generated. Third stage: It's really strange as in this stage, it again builds and build getting failed in this stage citing code for Non Released Dependencies for the jars that are uploaded in the git hub.

What might be the reason for this: When it can build in the first two stages of the Github cycle and getting failed in the third stage for Build Failure for non-released dependencies.

The pipeline is designed in such a way that it looks only on Nexus 3 and build during each phase of the cycle.

hawk base
  • 21
  • 3
  • 10
  • Then talk to the people who manage Nexus. Putting your artifacts into Nexus is the right way to do it. Git is not meant for hosting dependencies. – J Fabian Meier Aug 13 '19 at 10:49
  • The request has been made to add those libraries in the Nexus 3 but it's not going to happen anytime soon. It's running on the pipeline. I am not authorized to set up a custom repository manager. – hawk base Aug 15 '19 at 10:30
  • Then talk to your boss and tell him/her that you cannot add the libraries you want to add because the Nexus people don't add them. Constructing ways to circumvent company restrictions is not the purpose of stackoverflow. Either your boss pressures the issue and you get the libraries sooner or you need to go without and handle your problems without the libraries. – J Fabian Meier Aug 15 '19 at 11:12

1 Answers1

0

In the repositories, I gave the URL of the git hub repo of the jar folder

That does not work because your lib folder is not a valid Maven repository.

How can I reference this jar folder so that the Jenkins Pipeline can take it?

You have some options:

  1. Set up custom Maven repository manager. You can use Nexus Repository Manager or JFrog Artifactory or something else. It will give you the greatest flexibility and allow to do a lot more in the future. Downside is, you will need to have the infrastructure to run this which usually comes with some sort of maintenance cost.

  2. Install the bundles in Maven's local repo from the jar folder you already have. There are two ways you can do that:

    1. Via script in Jenkins Pipeline that runs before your build and calls mvn install-file ... for each library in your jar folder. You can find the exact syntax for this command on Apache Maven Install Plugin site

    2. By changing your build and calling the install-file goal of the maven-install-plugin in earlier build phase. I've personally never done that but this answer suggests it's possible.

  3. remove the files from the jar folder and create a wrapper project for each of them which does nothing but install the jar in the local maven repository. Make sure those are the first modules to run in your multi-module project.

Milen Dyankov
  • 2,972
  • 14
  • 25
  • I can’t upload these libs in Nexus. The pipeline picks all the lib from Nexus except these libs as these lib not available. It’s a pipeline and don’t access to Jenkins or scripts. I can’t use file parameter as pipeline won’t pick from local and that’s the reason uploaded these dependencies in Git Hub. – hawk base Aug 13 '19 at 16:16
  • Have you talked to the administrator of your Nexus if he/she can place your libs there? – J Fabian Meier Aug 13 '19 at 17:18
  • It's not possible to add these set of libs in Nexus 3. The pipeline is built on Nexus 3 and all the libs are available only on Nexus 2. – hawk base Aug 14 '19 at 01:30
  • You didn't specify what you have access to so I listed all the options I could think of. I assume you do have access to your projects code repo (Since you pleased the jars in it). So: For 1 you don't have to use use the same Nexus, it can be a different instance which you configure in the POM. For 2.1 may be you can modify the Jenkinsfile that contains the pipeline and should be committed to your repo. For 3 all you need is some other Maven modules in your existing repository. Keep in mind Jenkins is checking out the code (with jars you put in it) so you do have them on the FS – Milen Dyankov Aug 14 '19 at 12:24
  • Thanks for the reply. Added details. Please let me know if you need more explanation. – hawk base Aug 15 '19 at 00:58
  • Have you tried to avoid the libs? Maybe you can replace them by libs that are already available or write the relevant code yourself. – J Fabian Meier Aug 15 '19 at 13:02
  • @hawkbase how does the first stage build differ from the third stage build? – Milen Dyankov Aug 16 '19 at 12:08
  • Thanks for the replies. I was able to upload the libs in Nexus 2 ( not on Nexus 3) and now I was able to build a snapshot and upload the artifact to Nexus 3. But during next cycle I.e Deployment Cycle , it was not able to pick the artifact uploaded in Nexus 3 and saying Build Failure Error: can’t release project due to Non Released Dependencis of the libraries that I uploaded in Nexus 2. – hawk base Aug 17 '19 at 17:41