I am trying to run build of tests from jenkins
After all the 16 tests success's and I got the message BUILD SUCCESS I got this lines
[INFO] Tests run: 16, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 06:15 min
[INFO] Finished at: 2022-03-20T12:36:01 02:00
[INFO] ------------------------------------------------------------------------
[BE UAT] $ cmd.exe /C '""C:\Program Files\Selenium\apache-maven-3.8.1\bin\mvn.cmd"' mvn compile && exit %%ERRORLEVEL%%"
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------------< Maven:miron >-----------------------------
[INFO] Building miron 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.073 s
[INFO] Finished at: 2022-03-20T12:36:02 02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase "mvn". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [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/LifecyclePhaseNotFoundException
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE
Jenkins config
Why is that ?
CodePudding user response:
This is the command that's executed:
[BE UAT] $ cmd.exe /C '""C:\Program Files\Selenium\apache-maven-3.8.1\bin\mvn.cmd"' mvn compile && exit %%ERRORLEVEL%%"
As you can see, the cmd.exe
is running mvn.cmd
with mvn compile
as arguments. In other words, you're running mvn mvn compile
.
Edit: if you are using a "classic" freestyle job with an "Invoke top-level Maven targets" step, the Maven goals should not contain mvn
. The Maven command is built from the goals (clean
, package
, etc.) and options (-DsomeOption=someValue
). In freestyle jobs, you can add options either as part of the goals (in which case they should include the -D
prefix), or separately as part of the options under "Advanced" (in which case you should omit the -D
prefix).