我的任务是在一个tomcat web服务器上运行两个Jenkins实例。在我的server.xml文件中,我为两个Jenkins设置了两个具有不同端口,主机等的服务名称。
但是,我遇到的问题是它们都使用相同的JENKINS_HOME目录。第一个例子,我让它使用默认位置(在我的情况下是/home/jenkins/.jenkins)。第二个例子,我希望它使用/home/jenkins/.j2。但是,我很难做到这一点。
我的server.xml文件中的代码段
<!-- first instance of Jenkins. it is using the default Jenkins home and working fine -->
<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
<!-- trying to force it to use the second Jenkins home for the second instance of Jenkins -->
<!-- got this trick from another stackoverflow answer -->
<Context docBase="/glide/bigdata/tomcat/webapps2/jenkins.war" path="" reloadable="true">
<Environment name="JENKINS_HOME" value="/home/jenkins/.j2" type="java.lang.String"/>
</Context>
<!-- second instance of Jenkins. not working nicely -->
<Service name="j2">
<Connector port="8081" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="j2" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps2" unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
我可以在catalina.out日志文件中看到它正在扩展相应的war文件,但JENKINS_HOME仍然是/home/jenkins/.jenkins。 我需要做什么才能使第二个实例使用第二个Jenkins主页?在此先感谢您的帮助。
答案 0 :(得分:0)
更新上下文值
<Context ...>
<Environment name="JENKINS_HOME" value="/path/to/jenkins_home/" type="java.lang.String"/>
</Context>
引用https://wiki.jenkins.io/display/JENKINS/Tomcat
PS:最初,您可能必须将设置文件从 .jenkins / * 复制到 / path / to / jenkins_home / < / p>
通过相同的方法,您可以通过更改应用程序名称来创建单独的实例。