I installed jenkins on Cnetos 7 using the following:
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --impor
I had a similar issue on CentOS 7 while a correct version of Java was installed and java -version
gave a nice result.
Collecting multiple answers from different SO threads I did the following:
Make sure Java is installed (and version is compatible with Jenkins) There're some tricks if saying about CentOS, this is mentioned in official Jenkins tutorial here
If Java is installed and available, when running java -v
output should look like this:
~>$java -version
openjdk version "1.8.0_161"
OpenJDK Runtime Environment (build 1.8.0_161-b14)
OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)
Add a path to Java to your /etc/rc.d/init.d/jenkins
~>$ sudo vim /etc/rc.d/init.d/jenkins
candidates="
/etc/alternatives/java
/usr/lib/jvm/java-1.8.0/bin/java
/usr/lib/jvm/jre-1.8.0/bin/java
/usr/lib/jvm/java-1.7.0/bin/java
/usr/lib/jvm/jre-1.7.0/bin/java
/usr/bin/java
/usr/java/jdk1.8.0_162/bin/java ##add your java path here
"
How to get your 'real' path to java distributive which is called when you type smth like java -v
Follow this SO thread
If steps above didn't help, try to make sure all permission issues are resolved:
jenkins
user doesn't have permissions to run it, then change jenkins
to root
in config (described here)chmod
setting 755
permissions to java
installation folderAnd finally what helped me in result
When I did run journalctl -xe
as was suggested when I've tried to sudo service jenkins start
, I got similar Java stacktrace:
Starting CloudBees Jenkins Enterprise Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at Main._main(Main.java:140)
at Main.main(Main.java:98)
Caused by: java.lang.UnsatisfiedLinkError: /tmp/jna--1712433994/jna7387046629130767794.tmp: /tmp/jna--1712433994/jna7387046629130767794.tmp: failed to map segment from shared object: Operation not permitted
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1937)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1822)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:761)
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:736)
at com.sun.jna.Native.(Native.java:131)
at com.sun.akuma.CLibrary.(CLibrary.java:89)
at com.sun.akuma.JavaVMArguments.resolvePID(JavaVMArguments.java:128)
at com.sun.akuma.JavaVMArguments.ofLinux(JavaVMArguments.java:116)
at com.sun.akuma.JavaVMArguments.of(JavaVMArguments.java:104)
at com.sun.akuma.JavaVMArguments.current(JavaVMArguments.java:92)
at com.sun.akuma.Daemon.daemonize(Daemon.java:106)
at com.sun.akuma.Daemon.all(Daemon.java:88)
... 6 more
The problem is that Jenkins tries to launch JNA
library from /tmp
dir which is marked as noexec
by default, so we it could be fixed by creating a temporary directory in a /jenkins
path so it could be executed.
The full way to do this is described here by CloudBees support (thanks a lot for them)
I hope something from this list will help (as well I mostly leave it for me in the future when I'll have to install Jenkins for CentOs again :)