I have added the following in my POM so that I can use the Maven enforcer ruleset -
...
</plugins>
</pluginManagement>
</build>
</project>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>enforce-no-snapshots</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireReleaseDeps>
<message>No Snapshots Allowed!</message>
<excludes>
<exclude>org.apache.maven:maven-core</exclude>
</excludes>
</requireReleaseDeps>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
...
</plugins>
</pluginManagement>
</build>
</project>
But I am getting this error when running goal mvn enforcer:enforce
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.405s
[INFO] Finished at: Tue Sep 01 14:35:26 IST 2015
[INFO] Final Memory: 11M/240M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.4.1:enforce (default-cli) on project XXX
QAParent: The parameters 'rules' for goal org.apache.maven.plugins:maven-enforcer-plugin:1.4.1:enforce are missing or in
valid -> [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/PluginParameterException
Can someone help please???
I was getting the same error when using maven-enforcer-plugin:1.4.1 with maven:3.0.5. Downgrading the enforcer version to 1.3.1 did the trick. You may have to downgrade to a lower version (like 1.0.1) if you are using an even older version of maven.
Related
Goal :
I needed the maven build cycle to be completed/successful so a report would be generated.
But how can I show in Jenkins that there a test failure without canceling the build?
-Steps:
mvn clean verify
test runs
see's test method passes or fail
build is successful, a report is generated.
-Wants :
In Jenkins - show a red icon if there is a failure in the test (TestNg) despite the build is successful.
-Why? :
I don't want to view the report every day just to see if there's a failure.
Quick glance at the Jenkins Dashboard to see if there was a failure.
Here's my console output for context.
10:51:16
10:51:16 ===============================================
10:51:16 TEST FRAMEWORK DEMO 1 PASS 1 FAIL
10:51:16 Tests run: 2, Failures: 1, Skips: 0
10:51:16 ===============================================
10:51:16
10:51:16 [ERROR] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 5.405 s <<< FAILURE! - in TestSuite
10:51:16 [ERROR] com.demo.runnertypes.DemoTest.runScenario Time elapsed: 1.473 s <<< FAILURE!
10:51:16 org.openqa.selenium.InvalidSelectorException:
10:51:16 invalid selector: Unable to locate an element with the xpath expression //input[#id='password']invalidXpath because of the following error:
10:51:16 SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//input[#id='password']invalidXpath' is not a valid XPath expression.
10:51:16 (Session info: headless chrome=78.0.3904.97)
10:51:16 For documentation on this error, please visit: http://seleniumhq.org/exceptions/invalid_selector_exception.html
10:51:16 Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
10:51:16 System info: host: 'fmdat01ap01.unix.ctcwest.ctc', ip: '192.168.241.251', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-1062.4.1.el7.x86_64', java.version: '1.8.0_212'
10:51:16 Driver info: org.openqa.selenium.chrome.ChromeDriver
10:51:16 Capabilities [{networkConnectionEnabled=false, chrome={chromedriverVersion=77.0.3865.40 (f484704e052e0b556f8030b65b953dce96503217-refs/branch-heads/3865#{#442}), userDataDir=/tmp/.com.google.Chrome.kiacKj}, timeouts={implicit=0, pageLoad=300000, script=30000}, pageLoadStrategy=normal, unhandledPromptBehavior=dismiss and notify, strictFileInteractability=false, platform=LINUX, proxy=Proxy(), goog:chromeOptions={debuggerAddress=localhost:33385}, acceptInsecureCerts=false, browserVersion=78.0.3904.97, browserName=chrome, javascriptEnabled=true, platformName=LINUX, setWindowRect=true}]
10:51:16 Session ID: d6c2fbc4cbbd341cf6ef05609cb1e7a0
10:51:16 *** Element info: {Using=xpath, value=//input[#id='password']invalidXpath}
10:51:16
10:51:16 [INFO]
10:51:16 [INFO] Results:
10:51:16 [INFO]
10:51:16 [ERROR] Failures:
10:51:16 [ERROR] com.demo.runnertypes.DemoTest.runScenario
10:51:16 [INFO] Run 1: PASS
10:51:16 [ERROR] Run 2: DemoTest.runScenario » InvalidSelector invalid selector: Unable to locate an e...
10:51:16 [INFO]
10:51:16 [INFO]
10:51:16 [ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
10:51:16 [INFO]
10:51:16 [ERROR] There are test failures.
10:51:16
10:51:16 Please refer to /home/fmdigi/data/jenkins/workspace/CucumberTest/target/surefire-reports for the individual test results.
10:51:16 Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
10:51:16 [INFO]
10:51:16 [INFO] --- maven-jar-plugin:2.4:jar (default-jar) # testframework ---
10:51:17 [INFO] Building jar: /home/fmdigi/data/jenkins/workspace/CucumberTest/target/testframework-1.0-SNAPSHOT.jar
10:51:17 [INFO]
10:51:17 [INFO] --- cluecumber-report-plugin:2.3.1:reporting (report) # testframework ---
10:51:17 [INFO] ------------------------------------------------------------------------
10:51:17 [INFO] Cluecumber Report Maven Plugin, version 2.3.1
10:51:17 [INFO] ------------------------------------------------------------------------
10:51:17 [INFO] - source JSON report directory : /home/fmdigi/data/jenkins/workspace/CucumberTest/target/cucumber-report
10:51:17 [INFO] - generated HTML report directory : test-report/generated-cluecumber-report
10:51:17 [INFO] ------------------------------------------------------------------------
10:51:17 [INFO] - fail pending/undefined scenarios : false
10:51:17 [INFO] - expand before/after hooks : true
10:51:17 [INFO] - expand step hooks : false
10:51:17 [INFO] - expand doc strings : false
10:51:17 [INFO] - page title : Cluecumber Report
10:51:17 [INFO] - colors (passed, failed, skipped) : #28a745, #dc3545, #ffc107
10:51:17 [INFO] ------------------------------------------------------------------------
10:51:17 [INFO] => Cluecumber Report: test-report/generated-cluecumber-report/index.html
10:51:17 [INFO] ------------------------------------------------------------------------
10:51:17 [INFO] BUILD SUCCESS
10:51:17 [INFO] ------------------------------------------------------------------------
10:51:17 [INFO] Total time: 10.711 s
10:51:17 [INFO] Finished at: 2019-11-19T10:51:47-07:00
10:51:18 [INFO] Final Memory: 28M/571M
10:51:18 [INFO] ------------------------------------------------------------------------
10:51:18 [htmlpublisher] Archiving HTML reports...
10:51:18 [htmlpublisher] Archiving at BUILD level /home/fmdigi/data/jenkins/workspace/CucumberTest/test-output/HtmlReport to /var/lib/jenkins/jobs/CucumberTest/builds/15/htmlreports/ExtentHtml_Report
10:51:18 [htmlpublisher] Archiving at BUILD level /home/fmdigi/data/jenkins/workspace/CucumberTest/test-report/generated-cluecumber-report to /var/lib/jenkins/jobs/CucumberTest/builds/15/htmlreports/Test_Report
10:51:18 Collecting metadata...
10:51:18 Metadata collection done.
10:51:18 Finished: SUCCESS
POM.xml build phase
<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>
<plugins>
<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>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
<systemPropertyVariables>
<extent.reporter.html.start>true</extent.reporter.html.start>
<extent.reporter.html.out>test-output/HtmlReport/ExtentHtml.html</extent.reporter.html.out>
</systemPropertyVariables>
</configuration>
</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>
<plugin>
<groupId>com.googlecode.maven-download-plugin</groupId>
<artifactId>download-maven-plugin</artifactId>
<version>${maven-download-plugin.version}</version>
<executions>
<execution>
<id>install-chrome-driver-linux64</id>
<phase>generate-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>
https://chromedriver.storage.googleapis.com/${chromedriver-dep.version}/chromedriver_linux64.zip
</url>
<unpack>true</unpack>
<outputDirectory>${basedir}/drivers/linux/64bit/</outputDirectory>
</configuration>
</execution>
<execution>
<id>install-chrome-driver-windows</id>
<phase>generate-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>
https://chromedriver.storage.googleapis.com/${chromedriver-dep.version}/chromedriver_win32.zip
</url>
<unpack>true</unpack>
<outputDirectory>${basedir}/drivers/windows/</outputDirectory>
</configuration>
</execution>
<execution>
<id>install-chrome-driver-osx</id>
<phase>generate-resources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<url>
https://chromedriver.storage.googleapis.com/${chromedriver-dep.version}/chromedriver_mac64.zip
</url>
<unpack>true</unpack>
<outputDirectory>${basedir}/drivers/osx/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
I have all my Selenium tests in a separate project, away from other code. If this is not your case, the following might break your build!
Turn off the Surefire plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.plugin.version}</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
And substitute the Failsafe plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${surefire.plugin.version}</version>
<configuration>
<testFailureIgnore>false</testFailureIgnore>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
Note that the versions are intentionally the same!
From Failsafe site:
The Failsafe Plugin is designed to run integration tests while the Surefire Plugin is designed to run unit tests. The name (failsafe) was chosen both because it is a synonym of surefire and because it implies that when it fails, it does so in a safe way.
What this means is that when integration-tests fail, the build will continue, and will run your report which you have correctly defined in <phase>post-integration-test</phase>.
In order for Failsafe to pickup your tests, you can either rename everything from *Test to *IT, or configure the Failsafe plugin to pick your tests, explained here. Note that almost all configurations for Failsafe are the same as for Surefire. You might also want to read the TestNG configuration section.
You will still run everything just as you did, with: mvn clean verify.
One secret thing that Jenkins does is it overrides how integration-test failures are handled, using the testFailureIgnore flag. Jenkins overrides the default behaviour and will not flag the build as failed (the red icon). So for Jenkins you must set it back. This can easily be done in your pom with configuration <testFailureIgnore>false</testFailureIgnore>, or in Jenkins with setting MAVEN_OPTS to -Dmaven.test.failure.ignore=false.
Using the JUnit Plugin - via Publish JUnit test result report - made the build icon yellow/red depending on the config I wanted.
Deploy Spring Cloud project with docker, some code in the pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- tag::plugin[] -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
<dockerDirectory>src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
<!-- end::plugin[] -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
when i run the command: mvn package docker:build, it throws the error:
[INFO]
[INFO] --- spring-boot-maven-plugin:1.5.2.RELEASE:repackage (default) # eureka-server ---
[INFO]
[INFO] --- docker-maven-plugin:1.0.0:build (default-cli) # eureka-server ---
[INFO] Using authentication suppliers: [ConfigFileRegistryAuthSupplier]
[INFO] Copying /Users/eureka-server/target/eureka-server-0.0.1-SNAPSHOT.jar -> /Users/eureka-server/target/docker/eureka-server-0.0.1-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.728 s
[INFO] Finished at: 2017-11-15T20:51:07+08:00
[INFO] Final Memory: 41M/361M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build (default-cli) on project eureka-server: Exception caught: basedir src/main/docker does not exist -> [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/MojoExecutionException
my project has this file src/main/docker, how to solve it?
To add project path to the dockerDirectory:
<dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- tag::plugin[] -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
<dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
<!-- end::plugin[] -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
deploy Spring Cloud project with docker, some code in the pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- tag::plugin[] -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
<dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
<!-- end::plugin[] -->
</plugins>
</build>
when i execute the command: mvn package docker:build, it throws the above errors:
Downloaded: http://3.2.4.2:8888/repository/maven-public/org/apache/maven/plugins/maven-metadata.xml (14 KB at 5.7 KB/sec)
Downloaded: http://3.2.4.2:8888/repository/maven-public/org/codehaus/mojo/maven-metadata.xml (21 KB at 7.3 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] eureka-server ...................................... SUCCESS [ 26.279 s]
[INFO] service-1 ......................................... SUCCESS [ 14.649 s]
[INFO] demo1 ........................................... FAILURE [ 2.850 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 45.535 s
[INFO] Finished at: 2017-11-15T14:28:05+08:00
[INFO] Final Memory: 47M/532M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'docker' in the current project
and in the plugin groups [org.sonatype.plugins, org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/../Repository), nexus (http://3.2.4.2:8888/repository/maven-public/)]
how to solve it?
add the below code to your maven conf/setting.xml:
<pluginGroups>
<pluginGroup>com.spotify</pluginGroup>
</pluginGroups>
if you want to get more detail, pls refer to https://github.com/spotify/docker-maven-plugin/issues/322
If you are using dockerfile maven plugin, you need to change docker:build to
dockerfile:build and docker:push to dockerfile:push
For me worked in a different way, if you follow the maven plugin pattern {prefix}-maven-plugin... which in this case is dockerfile-maven-plugin, you should be able to run it with: mvn package dockerfile:build.
I'm using Maven: 3, Spring Boot 2 and Docker maven plugin 1.3.4
I tried to deploy my application using maven weblogic plugin. I get the below error message and not sure of what it means by 'artifact location not specified'.
[ERROR] Failed to execute goal com.oracle.weblogic:weblogic-maven-plugin:12.2.1-1-0:redeploy (default-cli) on project mdm_client: org.apache.maven.plugin.MojoExecutionException: The artifact location was not specified.
[ERROR] at weblogic.tools.maven.plugins.BaseMojo.getArtifactFile(BaseMojo.java:112)
[ERROR] at weblogic.tools.maven.plugins.deploy.RedeployMojo.populateParameters(RedeployMojo.java:297)
[ERROR] at weblogic.tools.maven.plugins.deploy.RedeployMojo.execute(RedeployMojo.java:263)
[ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
my application POM.xml
<!-- WebLogic Server 12c Maven Plugin -->
<plugin>
<groupId>com.oracle.weblogic</groupId>
<artifactId>weblogic-maven-plugin</artifactId>
<version>12.2.1-1-0</version>
<executions>
<execution>
<id>wls-redeploy</id>
<phase>development build</phase>
<goals>
<goal>redeploy</goal>
</goals>
</execution>
</executions>
<configuration>
<adminurl>t3://localhost:7001</adminurl>
<middlewareHome>C:/Oracle/Middleware</middlewareHome>
<domainHome>project</domainHome>
<user>${user}</user>
<password>${password}</password>
<name>${name}</name>
<remote>${remote}</remote>
<upload>${upload}</upload>
<targets>${targets}</targets>
</configuration>
</plugin>
You should put the ear, jar, war in the configuration
oracle doc
I'm trying to write a simple task using Maven:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<replaceregexp file="dir=target/liquibase/*.sql" match="**DATABASECHANGELOGLOCK**"
replace="" byline="true" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
When I run this, I get
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.3:run (default) on project Tik
[ERROR] Cause: the class org.apache.tools.ant.taskdefs.optional.ReplaceRegExp was not found.
[ERROR] This looks like one of Ant's optional components.
[ERROR] Action: Check that the appropriate optional JAR exists in
[ERROR] -ANT_HOME\lib
[ERROR] -the IDE Ant configuration dialogs
[ERROR]
[ERROR] Do not panic, this is a common problem.
[ERROR] The commonest cause is a missing JAR.
[ERROR]
[ERROR] This is not a bug; it is a configuration problem
[ERROR] -> [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/MojoExecutionException
I have included the ant and ant-nodeps dependencies, but can't make it run, and googling around hasn't been any help.
Does anyone have a solution for this?
I'm writing this in case anyone gets this problem
The problem was that maven doesn't care about ANT_HOME or anything. Dependencies must be declared inside the antrun plugin.
So I changed my pom.xml to look like this:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<dependencies>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.6.5</version>
</dependency>
</dependencies>
<executions><execution>...</execution></executions>
</plugin>
maven-antrun-plugin version 1.8 no longer has this problem. Its dependencies point to a newer version of Ant, so you no longer need to add a dependency to the plugin declaration in your pom.