Learning Continuous Integration with Jenkins(Second Edition)
上QQ阅读APP看书,第一时间看更新

Setting up the Jenkins home path

Before we start using Jenkins, there is one important thing to configure, the jenkins_home path. When you install Jenkins as a service on Tomcat, the jenkins_home path is automatically set to /root/.jenkins/. This is the location where all of the Jenkins configurations, logs, and builds are stored. Everything that you create and configure on the Jenkins dashboard is stored here.

We need to make it something more accessible, something like /var/jenkins_home. This can be done in the following way:

  1. Stop the Apache Tomcat server using the following command:
        sudo systemctl stop tomcat 
  1. Open the context.xml file for editing, which is present inside /opt/tomcat/conf:
        sudo nano /opt/tomcat/conf/context.xml
  1. The file will look like this (comments removed):
        <?xml version="1.0" encoding="UTF-8"?> 
        <Context> 
          <WatchedResource>WEB-INF/web.xml</WatchedResource> 
          <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource> 
        </Context>
  1. Add the following line between <Context> </Context>:
        <Environment name="JENKINS_HOME" value="/var/jenkins_home" 
type="java.lang.String"/>
  1. Start the Tomcat service using the following command:
        sudo systemctl start tomcat