I have been trying to install Jenkins on tomcat9 but when I go for the first time on http://myip:8080/jenkins to finish the setup; I have the the following error:
java.io.IOException: Read-only file system
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.createTempFile(File.java:2026)
at hudson.util.AtomicFileWriter.<init>(AtomicFileWriter.java:142)
Caused: java.io.IOException: Failed to create a temporary file in /var/lib/jenkins
at hudson.util.AtomicFileWriter.<init>(AtomicFileWriter.java:144)
at hudson.util.AtomicFileWriter.<init>(AtomicFileWriter.java:109)
at hudson.util.AtomicFileWriter.<init>(AtomicFileWriter.java:84)
at hudson.util.AtomicFileWriter.<init>(AtomicFileWriter.java:74)
at hudson.util.TextFile.write(TextFile.java:116)
at jenkins.model.Jenkins.<init>(Jenkins.java:910)
at hudson.model.Hudson.<init>(Hudson.java:85)
at hudson.model.Hudson.<init>(Hudson.java:81)
at hudson.WebAppMain$3.run(WebAppMain.java:262)
Caused: hudson.util.HudsonFailedToLoad
at hudson.WebAppMain$3.run(WebAppMain.java:279)
First: Tomcat9 is working well, I can access it locally or remortly
I have created /var/lib/jenkins which is owned by jenkins (unix user I have created), I have even setup the permission to 777.
Second: if i run the war in command line 'java -jar jankins.war" ( I have exported JENKINS_HOME=/var/lib/jenkins before), then jenkins works correctly. So the war is not corrupt.
third: on tomcat, I have modified the context.xml to set up JENKINS_HOME to /var/lib/jenkins, it is working as you can see the above error (5th line).
Then in context.xml I have tried to setup JENKINS_USER to several different users (jenkins, tomcat, root etc) , I tried different ownership for /var/lib/jenkins (and group as well).
here is my context.xml:
<Context>
<Environment name="JENKINS_HOME" value="/var/lib/jenkins" type="java.lang.String" />
<Environment name="JENKINS_USER" value="jenkins" type="java.lang.String" />
<!-- Default set of monitored resources. If one of these changes, the -->
<!-- web application will be reloaded. -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>WEB-INF/tomcat-web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
</Context>
But nothing is working, it looks like JENKINS_USER is not taken into account and/or whatever I do the directory is read-only ....
NB: as I have read there might be some issues with JDK version, so I have tried with open-jdk-11 (at the beginning) then with open-jdk-8
Has anyone face this issue ?
If you run tomcat9 from the Ubuntu repositories, it will run as the unix user tomcat. Providing access to a user jenkins won't give permissions to tomcat. And just defining arbitrary environment variables (JENKINS_HOME, JENKINS_USER) won't make a web application magically change its identity.
All web applications in tomcat run as the same user, and that's the one that you need to provide access to.
Also, notice that Debian's Tomcat runs in a sandboxed environment (see this answer to a relevant question), so you'll need to work on the sandbox environment in addition to the owner of the files/process.
Related
I want to set up 2 jenkins on same tomcat server -8.5.34 in linux.
I Downloaded https://get.jenkins.io/war-stable/latest/jenkins.war and placed in webapps folders of tomcat as jen-dev and jen-qa
However, for both Jenkins, I want to use different Jenkins home locations:
JENKINS1_HOME : /opt/jen-dev JENKINS2_HOME : /opt/jen-qa
If I try setting below variable in shell and start tomcat using bin/startup.sh, jen-dev is working fine as http://jenkins.dev.com/jen-dev.
export JENKINS_HOME="/opt/jen-dev"
How can I customize this installation to include second Jenkins home and run on same server as http://jenkins.dev.com/jen-qa?
There are three ways to set the JENKINS_HOME parameter (cf. Jenkins Wiki):
as a system environment variable,
as a system property,
as a JNDI environment entry.
The first two options will apply to the entire Tomcat server, so you need to use JNDI. Create a descriptor file $CATALINA_BASE/conf/Catalina/localhost/jen-dev.xml with content:
<Context>
<Environment type="java.lang.String" override="false"
name="JENKINS_HOME" value="/opt/jen-dev" />
</Context>
and define a similar descriptor for the other Jenkins instance.
Jenkins was up and running for months without issue, as a windows service.
I did some Jenkins updates (copied a newer/later .war file to the .jenkins folder) and some windows updates also occurred. The version that I have is Jenkins 2.263.3.
I did a lot of trolling through the documentation and other StackOverflow tickets and found out that the JENKINS_HOME environmental variable was missing. I added this.
Here is what my investigation reveals.
The Java environment variable is set - see below:
C:\>java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
JENKINS_HOME environmental variable is set - see below:
C:\>echo %JENKINS_HOME%
C:\Users\XXXXX\.jenkins
The Installation was under user XXXXX and the service account Log On was configured accordingly
I do not have another application using port 8080 - I checked this with sys internals.
My jenkins.xml looks like this:
<service>
<id>jenkins</id>
<name>Jenkins</name>
<description>This service runs Jenkins automation server.</description>
<env name="JENKINS_HOME" value="%BASE%"/>
<!--
if you'd like to run Jenkins with a specific version of Java, specify a full path to java.exe.
The following value assumes that you have java in your PATH.
-->
<executable>java</executable>
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war"</arguments>
<!--
interactive flag causes the empty black Java window to be displayed.
I'm still debugging this.
<interactive />
-->
<logmode>rotate</logmode>
<onfailure action="restart" />
<!--
In the case WinSW gets terminated and leaks the process, we want to abort
these runaway JAR processes on startup to prevent corruption of JENKINS_HOME.
So this extension is enabled by default.
-->
<extensions>
<!-- This is a sample configuration for the RunawayProcessKiller extension. -->
<extension enabled="true"
className="winsw.Plugins.RunawayProcessKiller.RunawayProcessKillerExtension"
id="killOnStartup">
<pidfile>%BASE%\jenkins.pid</pidfile>
<stopTimeout>10000</stopTimeout>
<stopParentFirst>false</stopParentFirst>
</extension>
</extensions>
<!-- See the referenced examples for more options -->
</service>
I can start Jenkins from the command line as follows:
java -Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "C:\Users\XXXXX\.jenkins\jenkins.war" --httpPort=8080 --webroot="C:\Users\XXXXX\.jenkins\war
If I try start it from the Serice Manager I get this error - System.BadImageFormatException
One last thing, once I start Jenkins from the command line, and login to the the application, I note the following Jenkins System log:
Feb 17, 2021 10:29:31 AM INFO hudson.WebAppMain$3 run
Jenkins is fully up and running
Feb 17, 2021 10:29:57 AM WARNING hudson.lifecycle.WindowsServiceLifecycle getBaseDir
Could not find environment variable 'BASE' for Jenkins base directory. Falling back to JENKINS_HOME
Any suggestions how to get the service to start via the Service Manager?
The service is starting and stopping without issue.
The problem I suspect was that the original install of Jenkins was very old, and I presume that it may have been a 32-bit application at the time. The current updates seem to 64-bit apps. Since the original install, Jenkins was updated - with changes spanning several major releases from the original install (.war file updates). The jenkins.exe file - that starts the service was never updated.
The error message 'System.BadImageFormatException' after much research indicated that the issue was related to compatibility difference between 32/64 bit executable. I presume it was expecting a 64-bit executable but was getting a 32-bit exe.
To solve this problem I installed the latest version of Jenkins on my local PC.
On the Server I backed up the files:
jenkins.exe
jenkins.exe.config
I then stopped Jenkins on the Server, where the Service was not Starting (from the terminal window with Ctrl+D).
I then replaced these 2 files on the server with the latest files from my local installation.
Service started the first time.
I have set up Guacamole 1.2.0 on Ubuntu server 20.04 which works great. Is it possible to bypass the login page in Guacamole 1.2.0 using the auth-noauth component from a previous Guacamole release? The release notes in 1.2.0 say the older components are compatible. I used guacamole-auth-noauth-0.9.14.tar.gz, but I still get the Guacamole login page come up.
This is what I did.
Downloaded guacamole-auth-noauth-0.9.14.tar.gz
Extracted the .jar file using tar xzf guacamole-auth-noauth-0.9.14.tar.gz
Copied the file guacamole-auth-noauth-0.9.14.jar to /etc/guacamole/[extensions,lib]
Amended my guacamole.properties file to:
guacd-hostname: localhost
guacd-port: 4822
user-mapping: /etc/guacamole/noauth-config.xml
auth-provider: net.sourceforge.guacamole.net.auth.noauth.NoAuthenticationProvider
noauth-config: /etc/guacamole/noauth-config.xml
Created a new noauth-config.xml file with the contents
<configs>
<config name="myconfig" protocol="rdp">
<param name="SVxxxx01" value="rdp-server" />
<param name="port" value="3389" />
</config>
</configs>
I then copied guacamole-auth-noauth-0.9.14.jar to the classpath directory I created cp guacamole-auth-noauth-0.9.14.jar /var/lib/guacamole/classpath
Any advice and tips to bypass the login page will be appreciated.
You should check if the plugin is correctly loaded. The tomcat logs (catalina.out) should write something like
"INFO o.a.g.extension.ExtensionModule - Extension "My guacamole extension" loaded.".
If it is not loaded, check if the location of the plugin is correct. Normally, the plugins are located in GUACAMOLE_HOME/extensions directory. You may see the default values for GUACAMOLE_HOME here: https://guacamole.apache.org/doc/gug/configuring-guacamole.html
I usually create extension directory in ~tomcat/.guacamole/extensions, but you should be fine with any other location specified in the documentation.
Sure enough changing the version of the extension worked! guacamole-auth-noauth-0.9.14.jar is not compatible by default but if you change the .jar extension to .zip, extract, edit guac_manifest.json to replace "0.9.14" with "1.2.0", re-zip (or replace), and optionally rename the whole thing guacamole-auth-noauth-1.2.0.jar (to avoid confusion) you end up with a working extension provided all other standard configuration steps are followed as well.
Is there any "adequate" way to change system properties in Jenkins? What is the easiest/fastest way change them? For instance, I need to turn off the useless (in my case) pinging thread.
If you really want a quick and simple way to change a system property, you can use the script console
System.setProperty("hudson.remoting.Launcher.pingIntervalSec", 0)
But that won't survive a restart. To make it permanent, add the setting to the java args. For me (CentOS, Jenkins 2.7.1) that's a line about halfway down /etc/sysconfig/jenkins (for other distributions I believe it's /etc/default/jenkins) where you should add your option to the existing list like this:
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Dhudson.remoting.Launcher.pingIntervalSec=0"
You'll have to restart Jenkins after you make that change (thanks Mark Tickner)
If you run Jenkins on windows as a service without tomcat, you can edit jenkins.xml. Add the property in <service><arguments> before the -jar.
Than restart the service.
<service>
<!-- ... -->
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -Dhudson.tasks.MailSender.SEND_TO_UNKNOWN_USERS=true -Dhudson.tasks.MailSender.SEND_TO_USERS_WITHOUT_READ=true -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war"</arguments>
The system properties available and how to set them are listed on the wiki:
https://wiki.jenkins-ci.org/display/JENKINS/Features+controlled+by+system+properties
To disable slave pinging, you can set hudson.remoting.Launcher.pingIntervalSec to 0.
System properties can be set in the same way as with any other Java program, e.g.:
java -Dhudson.remoting.Launcher.pingIntervalSec=0 -jar jenkins.war
If you use Tomcat on Windows you can edit the File C:\apache-tomcat-7.0.67\conf\catalina.properties and simply add the Line
hudson.DNSMultiCast.disabled=true
at the End of the File. Then safe the File and restart Tomcat.
I have the similar problem: I need to disable DNSMultiCast (set hudson.DNSMultiCast.disabled = false) and I can't understand how to do it
for example, https://wiki.jenkins-ci.org/display/JENKINS/Features+controlled+by+system+properties - there is such advice "...pass all of these arguments before the -jar argument..." but I run jenkins under tomcat so I am not sure I can change startup parameters.
I tried to change /etc/tomcat6/Catalina/localhost/jenkins.xml to
<?xml version="1.0" encoding="UTF-8"?>
<Context >
<Environment name="JENKINS_HOME" value="/var/jenkins"
type="java.lang.String" override="false"/>
<Environment name="hudson.DNSMultiCast.disabled" value="true"
type="java.lang.Boolean" override="false"/>
</Context>
but I didn't help.
Can someone explain how to change jenkins system properties when tomcat is used.
Maybe it's a bad hack but I set it in the pipeline job that needs the setting.
Like this:
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "") // allow formatted HTML pages to be published
It seems to work - as far as I can tell...
I followed each steps mentioned above but it fails.
So I did change the system time zone using timedatectl set-timezone Europe/London command and then I have restarted jenkins service service jenkins restart it worked.
I was using Rehdat 7.5
Jenkins version 2.168.
Jenkins Installed via yum install jenkins
I hope this will help some one.
I'm using the Grails stack on Heroku to deploy an app. I'd like to be able to serve my app with a root of myapp.herokuapp.com/xyz as opposed to myapp.herokuapp.com, in the same way I'm able to serve from root of localhost:8080/xyz in development. I've tried adding a grails.app.context in Config.groovy like so:
environments {
production {
grails.app.context = "/xyz"
}
}
But it doesn't seem to have an effect in deployment. Do I have to configure something with Heroku? Any ideas?
It looks like you have to add a jetty-web.xml file to the WEB-INF directory to set the context path:
<?xml version="1.0" encoding="UTF-8"?>
<!-- File: web-app/WEB-INF/jetty-web.xml -->
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
<Set name="contextPath">/xyz</Set>
</Configure>
If this helps proper credit goes to this site, which was linked from an article on Grails and Heroku by Tomas Lin.
I don't think you can set context path with the current Grails build pack. If you feel like it, you can fork the build pack and hack it to support setting context (see build pack doc for more info on build packs).
Another option is to build your Grails app locally into a WAR file and deploy the WAR file using WAR deployment. The WAR deployment process will use the webapp-runner utility to run your app with Tomcat and it supports configuring the context path. Here's the help output for webapp-runner 7.0.22.3 (what I happened to have installed, might be slightly out of date):
Tomcat Runner runs a Java web application that is represented as an exploded war in a Tomcat container
Usage: java -jar tomcat-runner.jar [arguments...] path/to/webapp
Arguments:
--session-timeout The number of minutes of inactivity before a user's session is timed out
--port The port that the server will accept http requests on
--context_xml The parth to the context xml to use
--path context path (default is /)
--session_manager session store to use (valid options are 'memcache')
--session_manager_operation_timeoutoperation timeout for the memcached session manager. (default is 5000ms)
--session_manager_locking_modeSession locking mode for use with memcache session store. (default is all)
--session_manager_ignore_patternRequest pattern to not track sessions for. Valid only with memcache session store. (default is '.*\.(png|gif|jpg|css|js)$'
As explained in the WAR deploy doc, you can set webapp-runner options for your webapp using the WEBAPP_RUNNER_OPTS config var.