简体   繁体   English

在詹金斯构建Maven -SNAPSHOT项目

[英]Build Maven -SNAPSHOT project in Jenkins

I believe that the answer will be really easy, but I haven't figure out how to do it. 我相信答案会很简单,但是我还没有弄清楚该怎么做。

The problem is: 问题是:

I have a third-party project, which is being cloned from github, so I'm not going to change anything there, but I need this project for my work with MUnit. 我有一个第三方项目,该项目是从github克隆的,因此我不会在此处进行任何更改,但是我需要该项目来进行MUnit工作。

The project is mule-interceptor-module and it has a version 3.4-M4-SNAPSHOT. 该项目是m子拦截器模块,并且具有版本3.4-M4-SNAPSHOT。

I created a build in Jenkins and I want to get mule-interceptor-module-3.4-M4-SNAPSHOT.jar after it, but Jenkins REMOVES -SNAPSHOT from the jar name and updates pom.xml with new version: 3.4-M4 instead of 3.4-M4-SNAPSHOT . 我在Jenkins中创建了一个版本,我想在此之后获取mule-interceptor-module-3.4-M4-SNAPSHOT.jar ,但是Jenkins从jar名称中删除了-SNAPSHOT并使用新版本更新了pom.xml:3.4-M4 3.4-M4-快照 The project, which uses this one (munit) in its dependencies has 3.4-M4-SNAPSHOT. 在依赖项中使用这一(munit)的项目具有3.4-M4-SNAPSHOT。 So I need the SNAPSHOT in version. 所以我需要SNAPSHOT版本。

What I tried to do: 我试图做的是:

I tried to build the same project on the server, which my Jenkins is installed on, using just mvn clean install and I got mule-interceptor-module-3.4-M4-SNAPSHOT.jar. 我尝试使用mvn clean install在安装了Jenkins的服务器上构建相同的项目,并且得到了mule-interceptor-module-3.4-M4-SNAPSHOT.jar。

The question is: 问题是:

How to tune Jenkins so that I could finally have SNAPSHOT build? 如何调整Jenkins,以使我最终可以构建SNAPSHOT?

My job setup: 我的工作设置:

Jenkins Console output Jenkins Console output wirh -X Jenkins控制台输出 Jenkins控制台输出wirh -X

The solution: 解决方案:

  1. in Jenkins /Configuration/Build/Advanced check in Use private Maven repository 在Jenkins / Configuration / Build / Advanced中检查使用私有Maven存储库
  2. Choose Strategy: Local to the workspace 选择策略:工作空间本地
  3. remove everything from /workspace folder by rm -R * 通过rm -R *从/ workspace文件夹中删除所有内容

@Grove: thanks you a lot for the support! @Grove:非常感谢您的支持!

I can see in the logs: Your branch is ahead of 'origin/3.4.x' by 1 commit. 我可以在日志中看到: Your branch is ahead of 'origin/3.4.x' by 1 commit. and Building Mule Interceptor Module 3.4-M4 . Building Mule Interceptor Module 3.4-M4 Could it be that your revision has 3.4-M4 as a version in the pom? 可能是您的修订版本在pom中有3.4-M4版本吗?

The solution: 解决方案:

  • in Jenkins /Configuration/Build/Advanced check in Use private Maven repository 在Jenkins / Configuration / Build / Advanced中检查使用私有Maven存储库
  • Choose Strategy: Local to the workspace 选择策略:工作空间本地
  • remove everything from /workspace folder by rm -R * 通过rm -R从/ workspace文件夹中删除所有内容

Why are using SNAPSHOT dependency from a 3rd party ? 为什么要使用第三方的SNAPSHOT依赖关系? The standard is to use a RELEASE version, right ? 标准是使用RELEASE版本,对吗?

Answer Anyways the fact that using the private maven repository worked for you proves just one thing, that the negative cache in your server's maven repo was causing the problem. 无论如何,要回答的事实是,使用私有Maven存储库对您有用的事实只是一件事,即服务器Maven存储库中的负缓存导致了问题。 See this Q and A from me more than a year back, when exactly the same solution worked for me, albiet for a different problem and I marked it as the answer. 看到这个问题与从我一年多前,当完全相同的解决方案为我,为albiet一个不同的问题,我将其标记为答案。 Only to find a few months later that I did not go to the root cause of the problem and just found a workaorund. 几个月后才发现我没有找到问题的根本原因,而只是找到了解决方法。

To test this theory, set <updatepolicy> true <updatepolicy> and use maven -U clean install . 要检验该理论,请将<updatepolicy> true <updatepolicy>设置为<updatepolicy> true <updatepolicy>use maven -U clean install It will have the same effect as your solution of using a private repo. 它将与使用私有存储库的解决方案具有相同的效果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM