Gradle build on Jenkins

The OpenShift forums have been retired.
You can still read and search them, but for help, please post a question on Stack Overflow.

Hi,

I'm having trouble getting Jenkins to build a Git repo using Gradle. I have the build script in the root of the project and I have setup a job to run in Jenkins, however when I run the job I seem to get the below error. I'm thinking that maybe there are no write permissions for Gradle in the var/lib/openshift/5b0acdc26ef649498cfb4e1da3b6d6bd directory and this could possibly be the cause, but I would like to see if anyone else has setup Gradle to work with Jenkins on Openshift and if they could give me a nudge in the right direction?

Started by user Jenkins Admin
Building in workspace /var/lib/openshift/5b0acdc26ef649498cfb4e1da3b6d6bd/app-root/data/jobs/Gradle Accounts Build/workspace
Checkout:workspace / /var/lib/openshift/5b0acdc26ef649498cfb4e1da3b6d6bd/app-root/data/jobs/Gradle Accounts Build/workspace - hudson.remoting.LocalChannel@67733f
Using strategy: Default
Last Built Revision: Revision a921ce62db9fe894e6072d82d2a53cae27d0ab0a (origin/develop)
Checkout:workspace / /var/lib/openshift/5b0acdc26ef649498cfb4e1da3b6d6bd/app-root/data/jobs/Gradle Accounts Build/workspace - hudson.remoting.LocalChannel@67733f
Fetching changes from 1 remote Git repository
Fetching upstream changes from https://github.com/irishshagua/accounts.git
Commencing build of Revision a921ce62db9fe894e6072d82d2a53cae27d0ab0a (origin/develop)
Checking out Revision a921ce62db9fe894e6072d82d2a53cae27d0ab0a (origin/develop)
[Gradle] - Launching build.
[workspace] $ /var/lib/openshift/5b0acdc26ef649498cfb4e1da3b6d6bd/app-root/data/tools/Gradle/gradle/bin/gradle build
 
FAILURE: Build aborted because of an internal error.
 
* What went wrong:
Build aborted because of an unexpected internal error. Please file an issue at: http://forums.gradle.org.
 
* Try:
Run with --debug option to get additional debug info.
 
* Exception is:
org.gradle.internal.nativeplatform.NativeIntegrationException: Could not create JNA native library '/var/lib/openshift/5b0acdc26ef649498cfb4e1da3b6d6bd/.gradle/native/jna/linux-i386/libjnidispatch.so'.
    at org.gradle.internal.nativeplatform.jna.JnaBootPathConfigurer.configure(JnaBootPathConfigurer.java:64)
    at org.gradle.internal.nativeplatform.services.NativeServices.initialize(NativeServices.java:61)
    at org.gradle.logging.internal.ConsoleConfigureAction.execute(ConsoleConfigureAction.java:30)
    at org.gradle.logging.internal.ConsoleConfigureAction.execute(ConsoleConfigureAction.java:27)
    at org.gradle.logging.internal.OutputEventRenderer.attachConsole(OutputEventRenderer.java:68)
    at org.gradle.logging.internal.DefaultLoggingManager.attachConsole(DefaultLoggingManager.java:149)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:168)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
    at org.gradle.launcher.Main.doAction(Main.java:48)
    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    at org.gradle.launcher.Main.main(Main.java:39)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:26)
Caused by: java.io.FileNotFoundException: /var/lib/openshift/5b0acdc26ef649498cfb4e1da3b6d6bd/.gradle/native/jna/linux-i386/libjnidispatch.so (No such file or directory)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:212)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:165)
    at org.gradle.internal.nativeplatform.jna.JnaBootPathConfigurer.configure(JnaBootPathConfigurer.java:54)
    ... 19 more
 
Build step 'Invoke Gradle script' changed build result to FAILURE
Build step 'Invoke Gradle script' marked build as failure
Sending e-mails to: brian_satchwannabe@hotmail.com
Finished: FAILURE

Ok, so it turns out there was no write permissions for where the gradle home got setup. Just in case anyone else has this problem, my build script uses gradle wrapper to build and sets thhhe home dir to a writeable directory.

Simple working script example is:

# Set a writable Gradle Home Dir
echo SETTING GRADLE HOME
export GRADLE_USER_HOME=$OPENSHIFT_DATA_DIR/gradle
 
# Mark gradlew as executable
chmod +x gradlew
./gradlew build

Yup only $OPENSHIFT_DATA_DIR is writable on the app gear; I am glad you were able to figure it out.

Thnx

I'm getting the same issue, even after applying the fix as mentioned above..

For others running into issues, @sgulati wrote a great blog here: https://www.openshift.com/blogs/run-gradle-builds-on-openshift