I am using maven verison 3.3.9 on linux-version: "4.4.0-43-generic". For somehow i can run the maven command using this way on console:
mvn -pl '!com.mycom.hp.comp:zonegtools,!com.mycom.hpe:testbed' -P compileWithGradle,nightly,flex-debug clear
double quotes inside the single quote i dont know the reason but it is working this way on console. I have a jenkins pipline in which i want to use this command but it is not working eiter i use:
sh ''' mvn -pl '"!com.mycom.hp.comp:zonegtools,!com.mycom.hpe:testbed"' -P compileWithGradle,nightly,flex-debug clear '''
OR use :
sh """ mvn -pl '"!com.mycom.hp.comp:zonegtools,!com.mycom.hpe:testbed"' -P compileWithGradle,nightly,flex-debug clear """
result will be given in a "!com.mycom.hp.comp:zonegtools,!com.mycom.hpe:testbed" OR '!com.mycom.hp.comp:zonegtools,!com.mycom.hpe:testbed'
Can someone tell me a proper way to use in jenkins script or inside a maven goal.
You can use
sh 'mvn -pl "!com.mycom.hp.comp:zonegtools,!com.mycom.hpe:testbed" -P compileWithGradle,nightly,flex-debug clear'
It should work.
If bash shell is used you have to escape !. with a backslash \. This works.
mvn -pl \!com.mycom.hp.comp:zonegtools
Ah , but this is not working in Jenkins groovy code.(2 backslashes)
sh "mvn -pl \\!com.mycom.hp.comp:zonegtools"
This does not work in jenkins+ groovy + maven
MVN error: Could not find the selected project in the reactor: !com.mycom.hp.comp:zonegtools
I can run mvn command in the groovy file like this. Could you try this?
run('mvn install:install-file -Dhttps.protocols=TLSv1.2 -DgroupId=com.sample-DartifactId=sample -Dversion=2.1.0 -Dpackaging=jar -Dfile=src/main/lib/sample-2.1.0.jar -DgeneratePom=true -Dmaven.test.skip=true')
Related
I have corporate Jenkins where I don't have access to Manage Jenkins option. I want to make a build of my java app using maven.
When I try to run mvn clean install:
dir("test/test2/project") {
sh "mvn clean install -Dmaven.test.skip=true"
}
I get the following error:
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/var/jenkins/workspace/test/test2/project). Please verify you invoked Maven from the correct directory.
I was trying to add mvn -f /var/jenkins/workspace/test/test2/project/pom.xml (I have pom file in the folder) but it did not work.
I also tried
withEnv(["PATH+MAVEN=${tool 'maven-3.5.0'}/bin:${env.JAVA_HOME}/bin"]) {
sh "mvn --batch-mode -V -U -e clean install -Dmaven.test.skip=true"
which also did not work.
I would like to point to maven and java which are installed on the agent but can't seem to sucseed.
Any idea?
Can you try something like below?
dir("test/test2/project") {
sh "mvn clean install"
}
Error message from the Jenkins console:
The goal you specified requires a project to execute but there is no
POM in this directory
(/home/jenkins/workspace/Dealer-API-v2-test-automation_qa). Please
verify you invoked Maven from the correct directory.
Maven command in the Jenkins file:
sh script : "mvn test '-Dkarate.options=--tags #regression' -Dtest=TestParallel -DargLine='-Dkarate.env=qa'"
How can I execute this maven command in my pipeline script?
Just a guess but if you add -f Dealer-API-v2-test-automation_qa/pom.xml or something like that, it may start working. Or do a cd Dealer-API-v2-test-automation_qa, before doing mvn test, hope that helps.
I am using below mentioned command to send jar from my local workspace to Artifcatory in maven repo. I am not using pom.xml to do so. I have configured setting.xml with credentials for Artifactory.
mvn deploy:deploy-file -Durl=https://myartifactory.fkc.com/maven-prereleases
-DrepositoryId= arti-mavenpre -Dfile=trial.zip -DgroupId=com/org/mydir
-DartifactId=test -Dversion=1.0 -Dpackaging=zip
I get following error while executing above command:
[ERROR] The goal you specified requires a project to execute but there is no
POM in this directory (C:\Users\raji\script). Please verify you invoked Maven
from the correct directory. -> [Help 1]
What am I doing wrong? I don't want to use pom.xml file. How to make it work without pom?
Thank you.
So this was the error. I am using powershell to execute maven command and it requires double quotes for execution. After using double quotes, its working fine.
C:\apache-maven-3.3.9\bin\mvn -s "C:\Users\my-user.m2\settings.xml" -Dversion="$(Build.BuildNumber)" -Durl="https://my-artifactory.ayz.com/maven-prereleases" -DgroupId="com.mycomp.mydir" -Dfile="C:\agent_work\1\a_PublishedWebsites\test_$(Build.BuildNumber).zip" -Dpackaging="zip" -DrepositoryId="my-artifac
tory" -DgeneratePom=true -DartifactId="test" -B deploy:deploy-file
The problem of your script is the empty space -DrepositoryId= arti-mavenpre between the repositoryId and the value. I had a similar problem and that fixed it.
I have more than 1 settings.xml file and I want to specify the 1 I want to use when I run > mvn from the command line, because running mvn help:effective-settings is showing 1 file but it seems that is using the other one
Use:
mvn --settings settingsYouWant.xml clean install
If you add the argument -X to your maven command (debug) you can see which one is picking.
I've added some gradle task to my project. However, I still want to continuous build to run maven. My first attempt was to add an explicit script
script:
- mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
- mvn test -B
This doesn't work. I tried to rename the build.gradle file. This doesn't work either. I probably need to remove gradlew but before that, is there a better solution?