0
votes

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]

1
You have a space ` - Dmaven...` you should change it to -Dmaven.repo.. ...? - khmarbaise
jenkins will already run a shell process for you, you don't need to type the bash -c in the jesnkins configuration textarea - guido

1 Answers

1
votes

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