Main Tutorials

Jenkins – Could not find GradleWrapperMain

Create a Gradle project in Jenkins CI, source management with Git, and build with Gradle Wrapper

1. Problem

Jenkins console output, the build is failed – “Could not find org.gradle.wrapper.GradleWrapperMain

[Gradle] - Launching build.
[workspace] $ /var/lib/jenkins/jobs/GradleTest/workspace/gradlew clean test

Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

Build step 'Invoke Gradle script' changed build result to FAILURE
Build step 'Invoke Gradle script' marked build as failure
Finished: FAILURE

2. Solution

2.1 The class GradleWrapperMain is inside the gradle-wrapper.jar, and Jenkins is unable to find it. I believe you forgot to check in the generated gradle-wrapper.jar

2.2 To fix it, create a Gradle wrapper again, and make sure the following files and folders are added to your version control system like GitHub.

|---gradle
    |---wrapper
        |---gradle-wrapper.jar
        |---gradle-wrapper.properties
|---gradlew
|---gradlew.bat 

Done.

References

  1. How to use Gradle Waapper
  2. Gradle Wrapper documentation

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
6 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
BoschVarun
5 years ago

Nope it’s not working
I have checked the folder and its completely intact, even then the error is not resolved

yujiaao
6 years ago

Yes, it helps

shreya
4 years ago

Thanks, worked for me.

khan
1 year ago

worked for me

khan
1 year ago
Reply to  khan

Thank you so much

Cagdas
1 year ago

thanks mkyong i kiss your eyes it saved my day