Azure DevOps运行Mule4未跳过MUnit时报错的版本兼容问题
问题现象
在Azure DevOps管道中构建运行Mule4项目时,若配置为不跳过MUnit测试执行,会触发部署错误,核心报错日志如下:
ERROR 2022-06-15 08:37:49,325 [Embedded] org.mule.runtime.module.deployment.internal.DefaultArchiveDeployer: 2022-06-15T08:37:49.3334578Z ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2022-06-15T08:37:49.3335465Z + Failed to deploy artifact + 2022-06-15T08:37:49.3336605Z + 'api-gateway-sample-wsdl-proxy', see below + 2022-06-15T08:37:49.3337593Z ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2022-06-15T08:37:49.3339247Z org.mule.runtime.api.exception.MuleRuntimeException: Artifact secure-properties requires a newest runtime version. Artifact required version is 4.2.0 and Mule Runtime version is 4.1.1 2022-06-15T08:37:50.9761979Z [INFO] ==================================================================================== 2022-06-15T08:37:50.9764107Z [INFO] MUnit Run Summary - Product: MULE, Version: 4.1.1 2022-06-15T08:37:50.9765113Z [INFO] ==================================================================================== 2022-06-15T08:37:50.9867345Z [INFO] >> wsdl-proxy-test-suite.xml (No tests run) <<< ERROR (org.mule.munit.remote.exception.DeploymentExceptio...) 2022-06-15T08:37:50.9872696Z [INFO] 2022-06-15T08:37:50.9921133Z [INFO] ==================================================================================== 2022-06-15T08:37:50.9922397Z [INFO] > Tests: 0 2022-06-15T08:37:50.9923046Z [INFO] > Errors: 0 2022-06-15T08:37:50.9923631Z [INFO] > Failures: 0 2022-06-15T08:37:50.9924229Z [INFO] > Skipped: 0
报错核心逻辑:secure-properties组件要求Mule Runtime最低版本为4.2.0,但管道中MUnit运行时实际使用的Mule Runtime版本为4.1.1,最终导致wsdl-proxy-test-suite.xml测试套件未执行任何用例就触发部署异常。修改pom.xml与mule-artifact.json中的版本配置后问题仍未解决。
现有配置片段
pom.xml 相关配置
<project xmlns=http://maven.apache.org/POM/4.0.0 xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd> <modelVersion>4.0.0</modelVersion> <groupId>org.mule.examples</groupId> <artifactId>api-gateway-sample-wsdl-proxy</artifactId> <version>2.0.1</version> <packaging>mule-application</packaging> <name>abc-app_name</name> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <app.runtime>4.3.0-20200824</app.runtime> <mule.maven.plugin.version>3.4.0</mule.maven.plugin.version> <munit.version>2.2.5</munit.version> <muleHttpConnector>1.5.17</muleHttpConnector> <muleCompressionModule>2.1.0</muleCompressionModule> <muleMavenPluginVersion>3.2.0</muleMavenPluginVersion> <proxyExtensionVersion>1.1.3</proxyExtensionVersion> <wsdlFunctionsExtension>1.1.3</wsdlFunctionsExtension> <soapFunctionsExtension>2.0.0</soapFunctionsExtension> <soap.validator.version>1.0.1</soap.validator.version> <attachMuleSources>true</attachMuleSources> </properties> <dependencies> <dependency> <groupId>com.mulesoft.modules</groupId> <artifactId>mule-secure-configuration-property-module</artifactId> <version>1.2.3</version> <classifier>mule-plugin</classifier> </dependency> <dependency> <groupId>com.mulesoft.munit</groupId> <artifactId>munit-runner</artifactId> <version>2.2.5</version> <classifier>mule-plugin</classifier> <scope>test</scope> </dependency> <dependency> <groupId>com.mulesoft.munit</groupId> <artifactId>munit-tools</artifactId> <version>2.2.5</version> <classifier>mule-plugin</classifier> <scope>test</scope> </dependency> </dependencies>
mule-artifact.json 相关配置
"redeploymentEnabled": true, "name": "org.mule.examples:api-gateway-sample-wsdl-proxy:2.0.1", "minMuleVersion": "4.1.0", "requiredProduct": "MULE", "classLoaderModelLoaderDescriptor": { "id": "mule",
问题根因与修复方案
修改配置未生效的核心原因是遗漏两个关键配置点,同时存在版本定义冲突,按以下步骤调整即可:
- 第一步修正
mule-artifact.json配置:当前文件内minMuleVersion值为4.1.0,该参数会直接声明应用支持的最低Mule版本,必须和实际使用的运行时版本对齐,直接修改为4.3.0,和pom.xml中app.runtime的大版本保持一致。 - 第二步解决pom内插件版本冲突:当前pom重复定义了两个Mule Maven插件版本,
mule.maven.plugin.version为3.4.0,muleMavenPluginVersion为3.2.0。MUnit运行时会读取低版本插件绑定的默认Mule Runtime,3.2.0版本插件默认绑定4.1.x系列运行时,这就是修改app.runtime后仍启动4.1.1版本运行时的核心原因。直接删除重复的muleMavenPluginVersion配置项,统一使用3.4.0版本的Mule Maven插件。 - 版本兼容性校验:当前使用的
mule-secure-configuration-property-module 1.2.3最低要求Mule 4.2.0,MUnit 2.2.5、HTTP连接器1.5.17、压缩模块2.1.0、SOAP相关扩展的现有版本均兼容Mule 4.3.0运行时,不需要额外调整依赖版本。 - 本地验证:配置修改完成后,在本地执行
mvn clean test -Dmunit.skip=false,观察启动日志中MUnit打印的Runtime版本为4.3.0、测试用例正常执行后,再将配置同步到Azure DevOps管道即可。
补充排查点:如果Azure DevOps管道任务中单独配置了Mule Runtime版本参数,会直接覆盖pom文件内的配置,需要同步检查管道变量、Mule构建任务的硬编码配置,若存在4.1.1版本的固定配置,修改为和pom一致的4.3.0版本。
内容的提问来源于stack exchange,提问作者Mule-Newbie
相关产品推荐
相关产品推荐

