多模块本地jar依赖项-Jenkins Pipeline [英] Multi-Module local jar dependencies - Jenkins Pipeline

查看:437
本文介绍了多模块本地jar依赖项-Jenkins Pipeline的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Maven上构建一个Java项目.我正在研究一个基于Nexus存储库中的Jenkins Pipeline构建的多模块Maven项目.我有一些库在Nexus存储库中不可用.我无法手动上传库.我正在管道上建立这个项目.

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.

我做了什么:

我在Git集线器存储库的项目根目录中创建了一个名为jars的文件夹,并手动将所有Nexus上不可用的jar文件放入.在依赖项中,我在依赖项参数中引用了所有这些本地jar.

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.

在存储库中,我给出了jar文件夹的git hub存储库的URL.詹金斯无法挑选图书馆.我收到以下错误:依赖项:依赖项版本-生成错误-无法针对未发布的依赖项生成,并且jar文件夹中的所有jar都出现错误.我尝试将jars文件夹放在src/main/resources中,但仍然遇到相同的错误.

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.

如何引用此jar文件夹,以便Jenkins Pipeline可以使用它?我无法控制所涉及的Jenkins/脚本.我是开发人员,只是在管道上构建它.

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:我无权访问公司的Internet来张贴POM或构建失败错误.

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

添加更多详细信息:

它是基于管道构建的.有两个存储库:Nexus 2和Nexus3.特定的库在Nexus 3上不可用,并且管道仅在Nexus 3上进行构建.

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.

我们已经提出了上传这些库的请求,但是这不会很快发生. Jenkins Pipelines从Github存储库中获取文件,并使用Maven构建Java项目.我无法控制管道或Jenkins中的任何脚本.

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.

我们下载了所有不可用的库,并将它们放在git hub的文件夹中.管道中有4个循环. Github周期/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周期:在此周期中,它分为三个阶段.它从代码中获取代码,然后进行构建.它生成快照并将其上传到Nexus存储库.在这两个阶段中,它能够通过从GitHub中获取代码并进行构建和生成的工件来成功构建.第三阶段:真的很奇怪,因为在此阶段,它再次构建,并且在该阶段构建失败,并引用了git中心中上传的jar的非发布依赖关系"的代码.

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.

这可能是什么原因:何时它可以在Github周期的前两个阶段进行构建,而在第三阶段因未发布的依赖项的构建失败而失败.

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.

管道的设计方式使其只能在Nexus 3上看到并在周期的每个阶段进行构建.

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

推荐答案

在存储库中,我给出了jar的git hub存储库的URL 文件夹

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

这不起作用,因为您的lib文件夹不是有效的Maven存储库.

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

如何引用此jar文件夹,以便Jenkins Pipeline可以 拿走吗?

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

您有一些选择:

  1. 设置自定义Maven存储库管理器.您可以使用 Nexus 存储库管理器 JFrog Artifactory 或其他工具. 这将为您提供最大的灵活性,并允许您做更多的事情 将来.缺点是,您将需要基础架构 运行该程序通常需要一定的维护成本.

  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.

从您已经拥有的jar文件夹中将捆绑软件安装在Maven的本地仓库中.有两种方法可以做到这一点:

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

    Jenkins Pipeline中的
  1. Via脚本在构建之前运行,并为jar文件夹中的每个库调用mvn install-file ....您可以在上找到此命令的确切语法. Apache Maven安装插件站点

  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

通过更改构建并在更早的构建阶段调用maven-install-plugininstall-file目标.我个人 从未做到过,但是此答案暗示有可能.

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.

  • jar文件夹中删除文件,并为每个文件创建一个包装项目,该项目除了将jar安装在 本地Maven存储库.确保这些是第一个要使用的模块 在您的多模块项目中运行.

  • 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.

    这篇关于多模块本地jar依赖项-Jenkins Pipeline的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆