Munit测试在Jenkins Docker容器中失败

时间:2019-02-21 18:06:03

标签: maven jenkins-pipeline munit

我试图使用本地的Jenkins docker容器中的maven命令运行此pom.xml。每次构建都会失败,并向我返回此错误

  

无法执行目标   com.mulesoft.munit.tools:munit-maven-plugin:2.1.4:test(test)on   项目ms3-sample-api:构建失败:错误:找不到或加载主程序   org.mule.munit.remote.RemoteRunner类

如果我跳过测试,则构建成功,并且此代码甚至可以在我的远程设备上运行,而不能在我的本地设备上运行。关于此的任何建议和关注。预先感谢

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.mycompany</groupId>
<artifactId>ms3-sample-api</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>mule-application</packaging>

<name>ms3-sample-api</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

    <app.runtime>4.1.4</app.runtime>
    <mule.maven.plugin.version>3.1.6</mule.maven.plugin.version>
    <munit.version>2.1.4</munit.version>
</properties>
  <build>
  <plugins>
      <plugin>
      <groupId>org.mule.tools.maven</groupId>
      <artifactId>mule-maven-plugin</artifactId>
      <version>${mule.maven.plugin.version}</version>
      <extensions>true</extensions>
    <configuration>

  <classifier>mule-application</classifier>
    </configuration>
    </plugin>
    <plugin>
    <groupId>com.mulesoft.munit.tools</groupId>
    <artifactId>munit-maven-plugin</artifactId>
    <version>${munit.version}</version>
            <executions>
          <execution>
                    <id>test</id>
                    <phase>test</phase>
                    <goals>
                        <goal>test</goal>
                        <goal>coverage-report</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <coverage>
                    <runCoverage>true</runCoverage>
                    <requiredApplicationCoverage>0</requiredApplicationCoverage>
                    <requiredResourceCoverage>0</requiredResourceCoverage>
                    <requiredFlowCoverage>0</requiredFlowCoverage>
                    <formats>
                        <format>html</format>
                        <format>console</format>
                        <format>json</format>
                    </formats>
                </coverage>
            </configuration>
        </plugin>
    </plugins>

<testResources>
    <testResource>
        <directory>src/test/munit</directory>
    </testResource>
    <testResource>
        <directory>src/test/resources</directory>
    </testResource>
    <testResource>
        <directory>src/main/mule</directory>
    </testResource>
</testResources>

</build>


<dependencies>
    <dependency>
        <groupId>org.mule.connectors</groupId>
        <artifactId>mule-http-connector</artifactId>
        <version>1.3.2</version>
        <classifier>mule-plugin</classifier>
    </dependency>
    <dependency>
        <groupId>org.mule.connectors</groupId>
        <artifactId>mule-sockets-connector</artifactId>
        <version>1.1.2</version>
        <classifier>mule-plugin</classifier>
    </dependency>
    <dependency>
        <groupId>org.mule.modules</groupId>
        <artifactId>mule-apikit-module</artifactId>
        <version>1.1.9</version>
        <classifier>mule-plugin</classifier>
    </dependency>
    <dependency>
        <groupId>com.mulesoft.munit</groupId>
        <artifactId>munit-runner</artifactId>
        <version>2.1.4</version>
        <classifier>mule-plugin</classifier>
        <scope>test</scope>
    </dependency>   
    <dependency>
        <groupId>com.mulesoft.munit</groupId>
        <artifactId>munit-tools</artifactId>
        <version>2.1.4</version>
        <classifier>mule-plugin</classifier>
        <scope>test</scope>
    </dependency>
</dependencies>

<repositories>
      <repository>
        <id>anypoint-exchange</id>
        <name>Anypoint Exchange</name>
        <url>https://maven.anypoint.mulesoft.com/api/v1/maven</url>
        <layout>default</layout>
    </repository>
    <repository>
        <id>mulesoft-releases</id>
        <name>MuleSoft Releases Repository</name>
        <url>https://repository.mulesoft.org/releases/</url>
        <layout>default</layout>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>mulesoft-releases</id>
        <name>mulesoft release repository</name>
        <layout>default</layout>
        <url>https://repository.mulesoft.org/releases/</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>
  </project>

1 个答案:

答案 0 :(得分:0)

当我们查看需要手动安装Java并在jenkins-> config工具中设置其路径的容器时,可以解决此问题。对我来说很好