我有 Mule 项目“A”,它指的是域项目“X”。我想在 Jenkins 中为项目“A”运行我的 MUnit,但它失败了,因为它无法找到依赖域项目“X”。为了解决这个问题,我在项目“X” pom.xml 中添加了域项目“A”的“依赖项”。xml。但没有运气。
请详细说明如何解决将我的 MUnits ion Jenkins 作为构建后操作运行的问题。
谢谢, 伊克拉姆
为了能够做到这一点,我必须:
首先,在您的 pom 中添加域依赖项,其范围为“test”
<dependency> <groupId>com.mygroupid</groupId> <artifactId>mule-domain-id</artifactId> <version>1.0.0</version> <scope>test</scope> <type>zip</type> </dependency>
其次,您必须在一个工件存储库(例如 Nexus)中安装域工件。这样,可以从 Jenkins 访问依赖项。然后将该存储库添加到您的 pom.xml
<repositories> <repository> <id>alm-nexus</id> <name>ALM Nexus Repo</name> <url>https://nexus.alm.corp/repository/maven-public</url> <layout>default</layout> </repository> </repositories>
在 Jenkins 中运行 MUnit 时,一件重要的事情如下。根文件夹名称必须与 artifactId 完全相同,因此在 Jenkins 中,您必须使用自定义设置工作区。如果使用 Jenkinsfile,您可以使用以下方法执行此操作:
customWorkspace "${env.JOB_NAME}/${env.BUILD_ID}/artifact-id-has-to-go-here"
通过这些步骤,我们能够拥有一个工作流水线,其中 MUnit 测试作为阶段之一。