Skip to content

Instantly share code, notes, and snippets.

@diegopacheco
Last active December 21, 2020 03:59
Show Gist options
  • Save diegopacheco/cc5a39352267e75b92c04a60ad4eb276 to your computer and use it in GitHub Desktop.
Save diegopacheco/cc5a39352267e75b92c04a60ad4eb276 to your computer and use it in GitHub Desktop.
How to install Jenkins on Jetty 9
wget http://central.maven.org/maven2/org/eclipse/jetty/jetty-distribution/9.4.5.v20170502/jetty-distribution-9.4.5.v20170502.zip
tar -xzvf jetty-distribution-9.4.5.v20170502.zip
rm -rf jetty-distribution-9.4.5.v20170502.zip

cd jetty-distribution-9.4.5.v20170502/
wget webapps/http://mirrors.jenkins.io/war-stable/latest/jenkins.war

sudo mkdir /home/jetty
sudo chown diego:diego /home/jetty
sudo sh -c "echo export JENKINS_HOME=/home/jetty/ > /etc/profile.d/systemwide.sh"

touch webapps/jenkins.xml
vim webapps/jenkins.xml
<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">

<!-- ==================================================================
Configure and deploy the jenkins web application in $(jetty.home)/webapps/jenkins

Note. If this file did not exist or used a context path other that /jenkins
then the default configuration of jetty.xml would discover the jenkins
webapplication with a WebAppDeployer.  By specifying a context in this
directory, additional configuration may be specified and hot deployments 
detected.
===================================================================== -->

<Configure class="org.eclipse.jetty.webapp.WebAppContext">


  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <!-- Required minimal context configuration :                        -->
  <!--  + contextPath                                                  -->
  <!--  + war OR resourceBase                                          -->
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <Set name="contextPath">/jenkins</Set>
  <Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/jenkins.war</Set>

  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <!-- Optional context configuration                                  -->
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <Set name="extractWAR">true</Set>
  <Set name="copyWebDir">false</Set>
  <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>

<Get name="securityHandler">
    <Set name="loginService">
      <New class="org.eclipse.jetty.security.HashLoginService">
        <Set name="name">Jenkins Realm</Set>
        <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
      </New>
    </Set>
    <Set name="authenticator">
      <New class="org.eclipse.jetty.security.authentication.FormAuthenticator">
        <Set name="alwaysSaveUri">true</Set>
      </New>
    </Set>
    <Set name="checkWelcomeFiles">true</Set>
  </Get>
</Configure>
bin/jetty.sh start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment