mercredi 20 novembre 2019

Maven Enforcement Rule - Show build fail in Jenkins

New to POM and Maven.

How do I create a Maven Enforcement Rule that shows the test failure even though the build passed, in Jenkins?

Scenario :

  1. Selenium tests run ( via testng.xml )
  2. Some tests failed
  3. Build passes
  4. Cucumber Report is generated.
  5. Build History Icon in Jenkins is now Green.

Goal :

  1. How do I enforce a rule so that I can show a "RED" icon instead ( Jenkins ), to indicate that there is a test failure?

enter image description here

Caveat :

  1. The report will not be generated if the Build lifecycle fails.

Here's my POM.

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.0.0-M4</version>
                    <configuration>
                        <suiteXmlFiles>
                            <suiteXmlFile>testng.xml</suiteXmlFile>
                        </suiteXmlFiles>
                        <testFailureIgnore>true</testFailureIgnore>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.1.0</version>
            </plugin>

            <plugin>
                <groupId>com.trivago.rta</groupId>
                <artifactId>cluecumber-report-plugin</artifactId>
                <version>${cluecumber-report.version}</version>
                <executions>
                    <execution>
                        <id>report</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>reporting</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <sourceJsonReportDirectory>${project.build.directory}/cucumber-report</sourceJsonReportDirectory>
                    <generatedHtmlReportDirectory>test-report/generated-cluecumber-report</generatedHtmlReportDirectory>
                    <expandBeforeAfterHooks>true</expandBeforeAfterHooks>
                </configuration>
            </plugin>

        </plugins>
    </build>
</project>

Aucun commentaire:

Enregistrer un commentaire