Question

I am new to jenkins.When I try to build a maven project, I meet an exception.

     [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]

How can I deal with it? Thanks

Était-ce utile?

La solution

I think what happened is that when you setup the Maven build step, you wrote mvn somegoal

The maven build step already implies the mvn command. So, in the goals section only write the goal. Don't explicitly write the mvn command.

Autres conseils

Remove mvn and provide the goals only. Example clean install package

Error: org.apache.maven.lifecycle.LifecyclePhaseNotFoundException 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

Solution : Unknown lifecycle phase or wrong goal example:First I am using "clean package tea-container-test:tomcat-test -P "XXX" -e" as goal , then I changed a goal as "test -P XXX" , then It works perfectly,so Please check , your goal is right or wrong. "Creates a new exception to indicate that the specified lifecycle phase is not defined by any known lifecycle".

In my case, the error was like this:

[ERROR] Unknown lifecycle phase ".1". 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]

The reason I found for this is I wrote -Dversion=1.1 and not -Dversion="1.1". This is why it was showing an error. I was trying to execute the following command in the .gitlab-ci.yml file:

script:
    - 'mvn -X -e org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file -Dfile="C:\Gitlab-Runner\builds\BAMAEMCW\0\hridoy\maven-project-with-ci-cd\lib\json-simple-1.1.jar" -DgroupId=json-simple -DartifactId=json-simple -Dversion="1.1" -Dpackaging=jar'

Now, it executes without any error. I think in your case, check if any typos occurred!

Unknown lifecycle phase perform-whitesource-scan getting this in configuration giving:

clean  deploy perform-whitesource-scan -Dwhitesource.scan.project.version=$POM_VERSION -Dws_ver=$POM_VERSION -P Sydney
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top