Maven Build Failure with "mvn install" command - java

I was trying to generate and test my codes (if working) for Cucumber-Maven report then opened command prompt. I have tried "mvn clean", it was BUILD SUCCESS. After that, I have tried "mvn install" and encountered BUILD FAILURE (error was shown).
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.844 s
[INFO] Finished at: 2019-02-05T13:14:51+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-surefire-plugin:2.20 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-surefire-plugin:jar:2.20: Could not transfer artifact org.apache.maven.plugins:maven-surefire-plugin:pom:2.20 from/to central (https://repo.maven.apache.org/maven2): Connect to webproxy.sample.com:8080 [webproxy.sample.com/205.165.7.13] failed: Connection timed out: connect -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
Here's my pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
</plugin>
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>4.3.0</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>ExecuteCucumberMavenAF</projectName>
<outputDirectory>${project.build.directory}/cucumber-reports-html</outputDirectory>
<cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
<skippedFails>true</skippedFails>
<enableFlashCharts>true</enableFlashCharts>
<buildNumber>42</buildNumber>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

It looks like proxy issue which is blocking the downloads of dependencies, so make some changes in settings.xml or create a one if it is not there.
Goto c:\users\youruser\.m2\settings.xml.
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<proxies>
<proxy>
<id>myproxy</id>
<active>true</active>
<protocol>http</protocol>
<username>user</username> <!-- Put your username here -->
<password>pass</password> <!-- Put your password here -->
<host>123.45.6.78</host> <!-- Put the IP address of your proxy server here -->
<port>80</port> <!-- Put your proxy server's port number here -->
<nonProxyHosts>maven</nonProxyHosts> <!-- Do not use this setting unless you know what you're doing. -->
</proxy>
</proxies>
</settings>

I tried using eclipse. I used maven clean and install for the same POM file. It is working fine.
Seems there is some issue with your C:\users\youruser\.m2\settings.xml file.
May be proxy issues which is blocking maven from downloading dependencies.
Please check your settings.xml file.

Related

Maven Nexus Issue - Authorization failed for 403 Forbidden

We have been on this issue for days now.
Created a Gitlab CI Pipeline for a Java App that reads dependencies from Maven and Nexus
The gitlab pipeline was configured to run as a nexus user with admin rights, this has been verified many times.
But, when the gitlab pipeline is executed we get the following error:
[ERROR] Failed to execute goal on project hello-component: Could not resolve dependencies for project x.y.z:hello-component:jar:1.6-SNAPSHOT: Failed to collect dependencies at a.b:c:jar:4.5.1132100: Failed to read artifact descriptor for b:c:jar:4.5.1132100: Could not transfer artifact a.b:c:pom:4.5.1132100 from/to maven-snapshots (http://host:8081/repository/maven-snapshots): Authorization failed for http://host:8081/repository/maven-snapshots/a/b/c/4.5.1132100/nidp-4.5.1132100.pom 403 Forbidden -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project hello-component: Could not resolve dependencies for project x.y.z:hello-component:jar:1.6-SNAPSHOT: Failed to collect dependencies at a.b:c:jar:4.5.1132100
I have also used the following guide:
https://blog.sonatype.com/how-to-use-gitlab-ci-with-nexus
My POM has the below, with env variables configured in ci/cd/settings/variables:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.5.1</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
<configuration>
<serverId>maven-snapshots</serverId>
<nexusUrl>http://host:8081/repository/maven-snapshots</nexusUrl>
<skipStaging>true</skipStaging>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>maven-snapshots</id>
<url>http://host:8081/repository/maven-snapshots</url>
</repository>
<repository>
<id>maven-releases</id>
<url>http://host:8081/repository/maven-releases</url>
</repository>
<!--repository>
<id>nexus.local</id>
<url>$HOME/.m2/repository</url>
</repository-->
</repositories>
<distributionManagement>
<snapshotRepository>
<id>maven-snapshots</id>
<url>http://host:8081/repository/maven-snapshots</url>
</snapshotRepository>
<repository>
<id>maven-releases</id>
<url>http://host:8081/repository/maven-releases</url>
</repository>
</distributionManagement>
The Gitlab CI runner has the following:
image: maven:3.3.9-jdk-8
variables:
GIT_STRATEGY: clone
MAVEN_CLI_OPTS: "-s /opt/apache-maven-3.6.3/conf/settings.xml --batch-mode"
MAVEN_OPTS: "-Dmaven.repo.local=/home/gitlab-runner/.m2/repository"
cache:
paths:
- /home/gitlab-runner/.m2/repository/
- target/
stages:
- build
CodeBuild:
stage: build
script:
- /opt/apache-maven-3.6.3/bin/mvn $MAVEN_CLI_OPTS -X clean package
artifacts:
name: “x—y-component"
paths:
- ./target/x—y-component.jar
Setting.xml on gitlab ci server has the following nexus user reference:
maven-snapshots
[adminuser]
[adminpassword]
Any help will be most appreciated.
Thanks
not sure if help is still needed but it seems that You did not grant necessary privileges to role of the user which You use for deployment/resolving dependencies. Please grant role nx-repository-view---* privilege. Test it and then you can decrease scope depend on your needs.
The issue at the time was with corporate proxy blocking download from maven central etc
Edit the proxies section in your maven settings.xml, which could be located in your ~/.m2/settings.xml file.
Settings.xml also exists in your MAVEN_HOME, so ensure you are updating the correct settings.xml
<settings>
<proxies>
<proxy>
<id>httpproxy</id>
<active>true</active>
<protocol>http</protocol>
<host>your-proxy-host</host>
<port>your-proxy-port</port>
<nonProxyHosts>add.host.that.needs.to.bypass.proxy.here|some.host.com</nonProxyHosts>
</proxy>
<proxy>
<id>httpsproxy</id>
<active>true</active>
<protocol>https</protocol>
<host>your-proxy-host</host>
<port>your-proxy-port</port>
<nonProxyHosts>add.host.that.needs.to.bypass.proxy.here|some.host.com</nonProxyHosts>
</proxy>
</proxies>
</settings>

Execute Appium test cases via Appcenter task in Azure Devops pipeline

How to configure correctly and execute the test cases using Appcenter task in the Azure VSTS pipeline.
In the repository, have two directories {source, testcase} in the parent directory. The build executes in hosted Mac OS triggered by VSTS pipleline.
In the first task, from source directory, create the .apk file and copy to artifacts staging directory.
In the second task, Run the Automated test cases using Appcenter task "Test with Visual Studio App Center".
I am having trouble understanding, how appium works and make it work via VSTS pipeline.
In the first approach, after the .apk buil then would like to execute the test cases using Appcenter and Appium. but it was not successful since one of my test case file has hardcoded values like below.
have one file /src/test/java/company/domain/com/util/android/UtilSetup.java which has hardcoded values like below. because of hard-coded values, it was looking for appium and it throws connection issues. so went on to second approach to make the pipeline work.
public class UtilSetupAndroid {
public static EnhancedAndroidDriver<MobileElement> driverAndroid;
public static void setupAndroid() throws MalformedURLException {
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(MobileCapabilityType.PLATFORM_NAME, Platform.ANDROID);
caps.setCapability("platformVersion", "7.0");
caps.setCapability("deviceName", "hexa-decimal-value-here");
caps.setCapability("udid", "same-hexa-decimal-value-here");
caps.setCapability("appPackage", "cl.company.transformacion.appcompanymobile");
caps.setCapability("appActivity",
"cl.company.transformacion.appcompanymobile.enrolamiento.activity.CargaInicialActivity");
caps.setCapability("app", "/home/directory/Appium-test/project.apk");
caps.setCapability("unicodeKeyboard", true);
caps.setCapability("resetKeyboard", true);
URL url = new URL("http://localhost:4723/wd/hub");
driverAndroid = Factory.createAndroidDriver(url, caps);
driverAndroid.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
}
}
In the second approach, did a local build(mvn test) and it has generated the *.class files of test cases. The committed the "test-classes" directory in the test cases build directory and referred in Appium configration secion. Committing the *.class files is not right approach i believe, but to make the pipeline work, did it like this.
Then, build pipeline started executing the Appium but ended with unresolved dependency error. I had the same issue and to overcome the issue, added the company nexus repository to directly download from Nexus. but still error occurs.
pom.xml has dependencies like below:
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>6.1.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.appcenter</groupId>
<artifactId>appium-test-extension</artifactId>
<version>1.0</version>
</dependency>
build section like below:
<profiles>
<profile>
<id>prepare-for-upload</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>3.0.0-M3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/upload/dependency-jars/</outputDirectory>
<useRepositoryLayout>true</useRepositoryLayout>
<copyPom>true</copyPom>
<addParentPoms>true</addParentPoms>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-help-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>generate-pom</id>
<phase>package</phase>
<goals>
<goal>effective-pom</goal>
</goals>
<configuration>
<output>${project.build.directory}/upload/pom.xml</output>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-testclasses</id>
<phase>package</phase>
<goals>
<goal>testResources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/upload/test-classes</outputDirectory>
<resources>
<resource>
<directory>${project.build.testOutputDirectory}</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>3.0.0-M3</version>
</plugin>
</plugins>
</reporting>
<repositories>
<repository>
<id>jcenter</id>
<url>https://jcenter.bintray.com/</url>
</repository>
</repositories>
</profile>
</profiles>
<repositories>
<repository>
<id>COMPAY_NAME.cl</id>
<url>http://maven.COMPANY_NAME.cl/nexus/content/repositories/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>COMPANY_NAME.cl</id>
<url>http://maven.COMPANY_NAME.cl/nexus/content/repositories/public/</url>
</repository>
</distributionManagement>
Error message:
Reason: [INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building run-test 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.microsoft.appcenter:appium-test-extension:jar:1.0 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.958 s
[INFO] Finished at: 2019-06-19T01:45:22+02:00
[INFO] Final Memory: 9M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project run-test: Could not resolve dependencies for project com.xamarin.appium:run-test:jar:1.0-SNAPSHOT: Could not find artifact com.microsoft.appcenter:appium-test-extension:jar:1.0 in cache1 (http://cache1:6081/maven2) -> [Help 1]
[EDIT]
Additional information, my pom.xml does not have the project in "com.xamarin.appium". It seems the error from App Center. Also the maven repo in the output is not my maven repository.
The REST call from appcenter-cli to App Center is returned with status 2xx for first few calls and finally throws the error.
[command]/usr/local/bin/appcenter test prepare appium --artifacts-dir /Users/vsts/agent/2.153.2/work/1/a/AppCenterTest --build-dir /Users/vsts/agent/2.153.2/work/1/s/Test/test_case --debug --quiet
Using appcenter-cli version: 1.1.18
Preparing tests... done.
Tests are ready to run. Manifest file was written to /Users/vsts/agent/2.153.2/work/1/a/AppCenterTest/manifest.json
[command]/usr/local/bin/appcenter test run manifest --manifest-path /Users/vsts/agent/2.153.2/work/1/a/AppCenterTest/manifest.json --app-path /Users/vsts/agent/2.153.2/work/1/a/AppCOMPMobile.apk --app COMPchile/AppAndroid --devices COMPchile/set-pruebas-vsts --test-series pruebas --locale en_US --debug --quiet --token ***
Using appcenter-cli version: 1.1.18
Preparing tests... done.
(truncated)
Response status code: 200
Body: {"message":["Tests completed. Processing data."],"wait_time":10,"exit_code":null}
Current test status: Tests completed. Processing data.
logFilter, request: {
"rawResponse": false,
"queryString": {},
"url": "https://api.appcenter.ms/v0.1/apps/COMPchile/COMPAppAndroid/test_runs/b8b88f0f-226c-4564-98b5-dc582cca81c8/state",
"method": "GET",
"headers": {
"Content-Type": "application/json; charset=utf-8",
"user-agent": "appcenterCli/1.1.18 NodeJS/v6.17.0 darwin/18.6.0",
"x-api-token": ***
},
"body": null
}
Response status code: 200
Body: {"message":["Failed!","Reason: [INFO] Scanning for projects...\n[INFO] \n[INFO] ------------------------------------------------------------------------\n[INFO] Building run-test 1.0-SNAPSHOT\n[INFO] ------------------------------------------------------------------------\n[WARNING] The POM for com.microsoft.appcenter:appium-test-extension:jar:1.5 is missing, no dependency information available\n[INFO] ------------------------------------------------------------------------\n[INFO] BUILD FAILURE\n[INFO] ------------------------------------------------------------------------\n[INFO] Total time: 2.132 s\n[INFO] Finished at: 2019-06-21T19:23:12+02:00\n[INFO] Final Memory: 10M/309M\n[INFO] ------------------------------------------------------------------------\n[ERROR] Failed to execute goal on project run-test: Could not resolve dependencies for project com.xamarin.appium:run-test:jar:1.0-SNAPSHOT: Could not find artifact com.microsoft.appcenter:appium-test-extension:jar:1.5 in cache1 (http://cache1:6081/maven2) -\u003e [Help 1]\n[ERROR] \n[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.\n[ERROR] Re-run Maven using the -X switch to enable full debug logging.\n[ERROR] \n[ERROR] For more information about the errors and possible solutions, please read the following articles:\n[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException\n"],"wait_time":10,"exit_code":2}

Maven dependency version dependent on JVM version

I'm trying to create a Maven POM which will pull in the correct version of alpn-boot when building the project and running the tests.
The whole thing works if I'm injecting the property from "outside" when running the build (e. g. via mvn -Dalpn-boot.version=8.1.8.v20160420 test or as an environment variable) but not when trying to interpolate it inside the POM using ${java.version}.
I've tried using properties-maven-plugin to accomplish this with the following settings in the pom.xml file (snippet):
<project>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${project.basedir}/alpn-boot/jdk-${java.version}.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.mortbay.jetty.alpn</groupId>
<artifactId>alpn-boot</artifactId>
<version>${alpn-boot.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Contents of one of the properties files:
$ cat alpn-boot/jdk-1.8.0_92.properties
alpn-boot.version=8.1.8.v20160420
Basically the same problem with the gmaven-plugin:
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
alpnVersions = [ '1.8.0_92': '8.1.8.v20160420' ]
project.properties['alpn-boot.version'] = alpnVersions[System.getProperty('java.version')]
</source>
</configuration>
</execution>
</executions>
</plugin>
With both approaches I get the following error message:
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'dependencies.dependency.version' for org.mortbay.jetty.alpn:alpn-boot:jar must be a valid version but is '${alpn-boot.version}'. # org.example:my-project:[unknown-version], /path/to/pom.xml, line 132, column 22
#
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project org.example:my-project:1.0.0-rc3-SNAPSHOT (/path/to/pom.xml) has 1 error
[ERROR] 'dependencies.dependency.version' for org.mortbay.jetty.alpn:alpn-boot:jar must be a valid version but is '${alpn-boot.version}'. # org.example:my-project:[unknown-version], /path/to/pom.xml, line 132, column 22
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
I ended up following the advice of #khmarbaise and add a Maven profile for each version of the JDK which needs to be supported:
<properties>
<!-- Default alpn-boot version. See <profiles> for specific profiles. -->
<alpn-boot.version>8.1.3.v20150130</alpn-boot.version>
</properties>
<dependencies>
<dependency>
<groupId>org.mortbay.jetty.alpn</groupId>
<artifactId>alpn-boot</artifactId>
<version>${alpn-boot.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<!-- Profiles for selecting the correct version of alpn-boot for each JDK.
see http://www.eclipse.org/jetty/documentation/current/alpn-chapter.html for reference. -->
<profiles>
<profile>
<id>jdk-1.8.0</id>
<activation>
<jdk>1.8.0</jdk>
</activation>
<properties>
<alpn-boot.version>8.1.0.v20141016</alpn-boot.version>
</properties>
</profile>
<!-- Lots of profiles [...] -->
<profile>
<id>jdk-1.8.0_92</id>
<activation>
<jdk>1.8.0_92</jdk>
</activation>
<properties>
<alpn-boot.version>8.1.8.v20160420</alpn-boot.version>
</properties>
</profile>
</profiles>

Maven build release ${project.basedir}:unknown

help me, please.
When I start a Perform Maven Release erro below appears:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.2.2:prepare (default-cli) on project JavaWeb: Cannot prepare the release because you have local modifications :
[ERROR] [${project.basedir}:unknown]
[ERROR] -> [Help 1]
My tags directory in SVN is empty.
Pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.2.2</version>
<configuration>
<tagBase>https://server01.com/svn/JavaWeb/tags/</tagBase>
<tag>${project.artifactId}-${maven.build.timestamp}</tag>
<preparationGoals>clean install</preparationGoals>
<goals>package</goals>
<arguments>-DskipTests=false</arguments>
<providerImplementations>
<svn>javasvn</svn>
</providerImplementations>
<checkModificationExcludes>
<checkModificationExclude>${project.build.directory}</checkModificationExclude>
</checkModificationExcludes>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.code.maven-scm-provider-svnjava</groupId>
<artifactId>maven-scm-provider-svnjava</artifactId>
<version>2.0.4</version>
</dependency>
</dependencies>
</plugin>
What's means that error? Is a problem in my repository?
Thanks.
Cannot prepare the release because you have local modifications : [ERROR] [${project.basedir}:unknown] [ERROR] -> [Help 1]
it means you have local code changes which needs to be checked in to your source control before you do release

Unable to send email after tests run using Maven Postman plugin

I've been trying all morning but have not had any success sending emails after running my Selenium test suite from the command line using Maven. Here is how we run the suite from the command line.
mvn surefire:test
This is using the Surefire plugin to run a suite of TestNG/Selenium tests. This works great and we want to keep using it. What I need is a way to email the results after each running of the suite. I came across the Postman plugin and it looks perfect. Only problem is I can't get it to work at all. Here is my maven .pom file.
<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>com.mysite.carelogic.selenium</groupId>
<artifactId>automation</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>carelogic-automation</name>
<description>automation tests for carelogic webapp</description>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.37.1</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.7</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>20030203.000129</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.8-beta4</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<plugin>
<groupId>ch.fortysix</groupId>
<artifactId>maven-postman-plugin</artifactId>
<version>0.1.6</version>
<executions>
<execution>
<id>send surefire notification</id>
<phase>deploy</phase>
<goals>
<goal>send-mail</goal>
</goals>
<inherited>false</inherited>
<configuration>
<skip>false</skip>
<from>conner#mysite.com</from>
<subject>Automation Test Results</subject>
<mailhost>relay.mysite.com</mailhost>
<htmlMessageFile>target/surefire-reports/emailable-report.html</htmlMessageFile>
<receivers>
<receiver>conner#mysite.com</receiver>
<receiver>conner#gmail.com</receiver>
</receivers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<showSuccess>true</showSuccess>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
I've confirmed with our techops that our mail server is relay.mysite.com and it is free to use on port 25. No user or password is necessary. When I run the maven command my tests run and I can see what passed and failed but I see no notification that maven tried to send any emails. So I have no idea where to start debugging to see what is wrong. Any help would be greatly appreciated.
*EDIT
Here is the command line output I get when running the above mvn command. As you can see there is no mention of the postman plugin or emails in general.
Results :
Failed tests:
Coleman.shouldBeAbleToVerifyClientCaseLoad:84->BaseSmokeTest.shouldBeAbleToVerifyClientCaseLoad:294 » NoSuchElement
Tests run: 2, Failures: 1, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 34.727s
[INFO] Finished at: Mon Feb 03 11:44:49 CST 2014
[INFO] Final Memory: 20M/141M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.16:test (default-test) on project automation: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Projects\automation\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.16:test (default-test) on project automation: There are test failures.
Please refer to C:\Projects\automation\target\surefire-reports for the individual test results.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures.
Please refer to C:\Projects\automation\target\surefire-reports for the individual test results.
at org.apache.maven.plugin.surefire.SurefireHelper.reportExecution(SurefireHelper.java:82)
at org.apache.maven.plugin.surefire.SurefirePlugin.handleSummary(SurefirePlugin.java:190)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:852)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:720)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Your Maven execution is never reaching the mail sending plugin because there are test failures. Add these lines in maven-surefire-plugin's configuration section :
<testErrorIgnore>true</testErrorIgnore>
<testFailureIgnore>true</testFailureIgnore>
That should solve your problems.
Maybe this can help!
Add the failsafe plugin to you pom.xml
And that would help maven to generate a report even if there are test failures. Then the Postman plugin will come into action.
Also, I am using the below path and tag for email attachments and it works fine for me.
<fileSets>
<fileSet>
<!-- Report directory Path -->
<directory>${project.build.directory}/site/serenity</directory>
<includes>
<!-- Report file name -->
<include>**/serenity-summary.html</include>
</includes>
<!-- Use Regular Expressions like **/*.html if you want all the html files to send-->
</fileSet>
</fileSets>
My failsafe plugin configuration is:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
All in all, what is happening here is that failsafe will allow maven to execute completely even when there are test failures and then fileset seems to be the correct tag to send an attachment.

Categories