简体   繁体   中英

Failed to run the mvn goals through shell script

I have below piece of code which will run the mvn goals through bash scripts in jenkins "Execute Shell".

 bash -c $M2_HOME/bin/mvn -f $WORKSPACE/pom.xml compile -Dmaven.repo.local=$WORKSPACE/.repository --settings/var/lib/jenkins/.m2/settings-amazon.xml

Tried below format but no luck:

 bash -c $M2_HOME/bin/mvn compile -f $WORKSPACE/pom.xml  - Dmaven.repo.local=$WORKSPACE/.repository -- settings/var/lib/jenkins/.m2/settings-amazon.xm`l

Exception:

[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format : or :[:]:. 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]

You probably don't have default goal , if you want to define it in pom.xml:

 <build> <defaultGoal>clean install</defaultGoal> </build> 

If not, add to mvn command the goal you want as :

  mvn clean install -f

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM