简体   繁体   English

Jenkins 有多个 Maven 目标的工作

[英]Jenkins job with multiple maven goals

I was assigned to maintain issues in a system created before time.我被指派维护在时间之前创建的系统中的问题。 The system uses Jenkins as system integration tool and unfortunately I do not have previous experience with it.该系统使用 Jenkins 作为系统集成工具,不幸的是我以前没有使用它的经验。

The problem is following: When following the steps for local build (via console) the archive files (.jars, .ear) are created correctly.问题如下:按照本地构建的步骤(通过控制台)正确创建存档文件(.jars、.ear)。 When using Jenkins job for this, one of the .jar files (call it module-one.jar) included in .ear does not contain a folder with .xsb and .class fiels.当为此使用 Jenkins 作业时,.ear 中包含的一个 .jar 文件(称为 module-one.jar)不包含带有 .xsb 和 .class 文件的文件夹。 So .ear application becomes incorrect and ClassNotFoundException is thrown.所以 .ear 应用程序变得不正确并抛出ClassNotFoundException

Steps for building application locally:在本地构建应用程序的步骤:

cd my_project_path
cd ModuleOne
mvn xmlbeans:xmlbeans
mvn install
cd ..
mvn clean install

The Maven section in Jenkins contains only this goal clean install (the screenshot below section "Build"): Jenkins 中的 Maven 部分仅包含此目标clean install (“构建”部分下方的屏幕截图):


So what I wonder is how to add the following maven tasks in Jenkins job to be executed on ModuleOne:所以我想知道的是如何在 Jenkins 作业中添加以下 maven 任务以在 ModuleOne 上执行:

mvn xmlbeans:xmlbeans
mvn install

My idea is to go to "Pre Steps" section and add following maven goal:我的想法是转到“Pre Steps”部分并添加以下 Maven 目标:

mvn xmlbeans:xmlbeans install

My questions are:我的问题是:
1. If I am on the right way how to define the goal "mvn xmlbeans:xmlbeans install" to be executed exactly on ModuleOne? 1.如果我在正确的方式上如何定义目标“mvn xmlbeans:xmlbeans install”在ModuleOne上完全执行?
2. If I am not on the right way are there at all any solutions to do this with Jenkins? 2. 如果我的方法不对,Jenkins 是否有任何解决方案可以做到这一点?

Here is screenshot with my suggestion for "Pre Steps".这是我对“Pre Steps”的建议的屏幕截图。 In the current configuration (that skips to add proper dirctory with .xsb and .class fiels to ModuleOne) this section is missing, but the section "Build" is as it is used now.在当前配置中(跳过将带有 .xsb 和 .class 文件的正确目录添加到 ModuleOne)该部分缺失,但“构建”部分与现在使用的一样。

Maven 构建设置

I think your approach is good!我觉得你的方法很好! But on "pre steps":但是在“前置步骤”上:

  • Remove "mvn" from Goals目标中删除“mvn”

  • Use Advanced configuration in order to specify the path of your pom.xml使用高级配置来指定 pom.xml 的路径

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

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