一尘不染

Jenkins和TestNG结果编码

jenkins

我正在使用Jenkins构建我的Maven项目并使用插件发布testng结果。报告中的西里尔符号有问题。看起来像:
。但是在Jenkins控制台中的西里尔文输出是可以的。

我的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">
  <properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <modelVersion>4.0.0</modelVersion>
  <groupId>ru.ibs</groupId>
  <artifactId>msprjtest</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>
    <dependencies>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.8.5</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.32.0</version>
        </dependency>
        <dependency>
            <groupId>com.opera</groupId>
            <artifactId>operadriver</artifactId>
            <version>1.2</version>
        </dependency>
    </dependencies>
    <build>
        <resources> 
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
        <plugin>
            <groupId>com.googlecode</groupId>
            <artifactId>maven-idea-plugin</artifactId>
            <version>1.6.1</version>
            <configuration>
            <!--vmParameters>-Dfile.encofing=UTF-8</vmParameters-->
            <compileInBackground>false</compileInBackground>
    </configuration>
        </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                <encoding>UTF-8</encoding>
                </configuration>
            </plugin> 
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.14.1</version>
                <configuration>
                    <reportsDirectory>${basedir}/test-output</reportsDirectory>
                    <suiteXmlFiles>
                        <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <pluginRepositories>
    <pluginRepository>
        <id>maven-idea-plugin-repo</id>
        <url>http://maven-idea-plugin.googlecode.com/svn/maven-repo</url>
    </pluginRepository>
    </pluginRepositories>
    <!-- profiles -->
    <profiles>
        <profile>
            <id>ie9</id>
            <properties>
                <env>local</env>
                <user.username></user.username>
                <user.password></user.password>
                <grid2.hub></grid2.hub>
                <site.url>http://msprjtest:6005/</site.url>
                <browser.name>ie</browser.name>
                <browser.version></browser.version>
                <browser.platform></browser.platform>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
    </profiles>
</project>

项目编码设置为UTF-8。IDE是Intellij IDEA 12.1.3。TestNG 6.8.5。


阅读 200

收藏
2020-07-25

共1个答案

一尘不染

其实,

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.14.1</version>
    <configuration>
        ...
        <encoding>UTF-8</encoding>
        <inputEncoding>UTF-8</inputEncoding>
        <outputEncoding>UTF-8</outputEncoding>
        <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -ea
        -Dfile.encoding=UTF-8</argLine>
    </configuration>
</plugin>

应该修复它。

2020-07-25