Maven wrapper in jenkins - maven

I'm trying to test build a maven based project in jenkins.
https://github.com/tonsV2/Lift-Log-Backend
However I get the following error.
[Lift Log Backend] $ /bin/sh -xe /tmp/hudson4180120395829748105.sh
+ ./mvnw clean
Error: Could not find or load main class org.apache.maven.wrapper.MavenWrapperMain
Build step 'Execute shell' marked build as failure
Finished: FAILURE
Any clues?

Seems like you have spaces in your Jenkins job name. Try to rename your job from "Lift Log Backend" to "Lift-Log-Backend"
I had the same issue, after renaming the Jenkins job, the error was gone.

Related

Jenkins maven projet build failed on fork during test

I'm building maven project on Jenkins (version 2.263.4, not the last but not so far).
It's a git project with pipeline configuration and webhook from bitbucket when push is done on the project.
So when a developper create a branch and another one a pull request, i have 2 build in parallel. Domain test running in about 45min.
And sometimes(not always), i have this error :
Command was /bin/sh -c cd /jenkins/workspace/a-hub_test-plantage-jenkins_PR-1/server/project-core/project-core-domain && /jenkins/tools/hudson.model.JDK/jdk11/jdk-11.0.2+9/bin/java -Xmx1500M -jar /jenkins/workspace/a-hub_test-plantage-jenkins_PR-1/server/project-core/project-core-domain/target/surefire/surefirebooter15630998754365374145.jar /jenkins/workspace/a-hub_test-plantage-jenkins_PR-1/server/project-core/project-core-domain/target/surefire 2021-05-04T12-39-54_622-jvmRun1 surefire5846464826560071036tmp surefire_13691263758446667285tmp
Error occurred in starting fork, check output in log
14:46:13 [ERROR] Process Exit Code: 1
14:46:13 [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:669)
14:46:13 [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:282)
14:46:13 [ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:245)
If i re run the buildin error, it work.
I'm using maven-surefire 2.22.2.
I try to configure it following many thread on stackoverfow, but nothgin work. I try with forkMode none or something else, it work but i loose coverage because jaccoco need fork to work. So i'm stuck.
What can i do to help me to debug this problem?
I don't understand why build failed when another one is building because for me Jenkins work on different working folder, no? so why the problem appear when i'have multiple build in parallel?
thanks for help
I find an hs_err_pid.log in jenkins near source code and i see out of memory! i see that my test was launch with -Xmx1500Mo and problem occured when i launched multiple branch/pr, so jenkins use all of the memory and failed all build during fork...i decrease -Xmx and all seems to work.

zip -urj command fails in jenkins pipeline shell script

I have jenkins job that add the files to existing zip file
Below is the command that I am using:
zip -urj ./$zipFileName ./template/CM/provision/start.sh
This runs sometimes and sometimes it fails
Here is the log i get on failure:
Build step 'Execute shell' marked build as failure

Go CI does not recognize build file for gradle

I have setup GO CI pipeline for continuous integration in my project. I tried to add a project that is built using gradle. I tried a add gradle task for building my application.
While executing build it shows that
FAILURE: Build failed with an exception.
* What went wrong:
Task 'build' not found in root project 'Gradlepipelinejob'.
I tried to add defaultTasks 'clean', 'compile' to the parent build.gradle file. But still the same error exists. Someone pls help me in resolving this issue.
I think 'build' should be in Command section, rather than arguments. Even after that if it doesn't works, try executing build commands in the agent terminal(or any command prompt).This will let you figure out whether the error is in server or agent.
GO CI runs the command in the code checkout directory so please check if your gradle file is present or not in that directory

Unable to execute maven command on jenkins

I have a jenkins job that checks out code from TFS and executes a test class using testng.xml
I have Maven properly installed in my machine in C:\JenkinsDependencies\apache-maven
It has mvn.bat file in its bin folder.
But when I execute my job, it fails with the following error.
Checking for pre-build
[TFS_LN_Mobile] $ cmd.exe /C '"C:\JenkinsDependencies\apache-maven\bin\mvn.bat test && exit %%ERRORLEVEL%%"'
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
Build step 'Invoke top-level Maven targets' marked build as failure
Checking for post-build
Finished: FAILURE
Below is the configuration of my jenkins job:
I manually executed a batch command as follows:
cd "C:\JenkinsRoot\workspace\TFS_LN_Mobile"
mvn test -DsuiteXmlFile=testng.xml
This works fine.
mvn.bat is a batch script. you can try adding trace of it's variables after steps that might produce this error. take a look at this: Is there any way to trace through the execution of a batch file?

Jenkins executing maven from incorrect path

This happens for both: maven projects, and freestyle projects, when maven target is envoked, it tries to execute mvn using absolute path.
[MY-Job] $ tools/Maven/Jenkins_Private_Maven/bin/mvn -f cc/pom.xml -Ddeploy_env=xxx.dev.prv -Dbranch=dev -D-Dsmdist.target=/opt/builds -U clean test -DtestGroups=unit,delegate -Do verride:server=xxx.dev.prv
FATAL: command execution failed
java.io.IOException: Cannot run program "tools/Maven/Jenkins_Private_Maven/bin/mvn" (in directory "workspace/MY-Job"): java.io.IOException: error=2, No such file or directory
I can see that mvn is installed at user's home :
/home/jenkins/tools/Maven/Jenkins_Private_Maven/bin/mvn
but it's trying to run it from the workspace:
/home/jenkins/workspace/MY-Job/tools/Maven/Jenkins_Private_Maven/bin/mvn
Add the default maven installation under (Jenkins -> configuration)
Goto the failing job and make sure you choose the default maven installation from dropdown
Run the job. Success!
Are you sure you have set up Maven in Jenkins -> configuration like this
I have hunch you have a accidental **"."** current directory reference somewhere in your maven set up.
This looks like an auto installed Maven by Jenkins. In which case the previous answers are not correct.
It would seem in this occasion that you have not specified a "remote fs root" for your slave in the salve setup - later versions of Jenkins flag not setting this up correctly as an error.
in Jenkins 2.43:
Manage Jenkins -> Global Tool Configuration -> Maven

Resources