在Tomcat7中设置JENKINS_HOME?


9

我正在尝试在Ubuntu的Tomcat7中设置Jenkins。我安装了Tomcat7并进行了部署jenkins.war,现在在可以看到Jenkins主页http://myhost:8080/jenkins,但是/usr/share/tomcat7/.jenkins出于安全原因,它试图在上创建Jenkins目录。我已经创建/srv/jenkins并授予了tomcat7组权限,并且想要设置JENKINS_HOME为该路径。我试过将它添加到tomcat配置中/etc/tomcat7/server.xml

<GlobalNamingResources>

  <Environment name="JENKINS_HOME" value="/srv/jenkins"
       type="java.lang.String" override="false"/>
  <!-- Default settings -->

而且我还尝试将其添加到中的自动创建的上下文文件中ROOT/META-INF/context.xml$CATALINA_HOME/conf据我所知没有)。

<Context path="/"
        antiResourceLocking="false" >
    <Environment name="JENKINS_HOME" value="/srv/jenkins/" type="java.lang.String"/>
</Context>

但是即使重新启动tomcat7之后,我仍然得到相同的结果(尝试使用/usr/share/tomcat7/.jenkins)。

我在哪里需要JENKINS_HOME在Tomcat7中设置环境变量?

Answers:


3

这并不是我偏爱的解决方案,但是我/usr/share/tomcat7/bin/setenv.sh按照所述创建了脚本catalina.sh

#!
export JENKINS_HOME=/srv/jenkins

当然,还给了它执行权限chmod ugo+x setenv.sh


3

我把它放进去了/etc/default/tomcat7。对于您的示例,请添加以下行:

JENKINS_HOME=/srv/jenkins

1

一种符号链接方法,我的詹金斯数据进入备份的文件系统。

[root@lx08 tomcat6]# ln -s /data01/jenkins .jenkins
[root@lx08 tomcat6]# ls -la
total 12
drwxrwxr-x    3 root root   4096 Dec 27 13:00 .
drwxr-xr-x. 181 root root   4096 Dec 27 11:28 ..
drwxr-xr-x    2 root root   4096 Dec 27 11:28 bin
lrwxrwxrwx    1 root tomcat   12 Dec 27 11:28 conf -> /etc/tomcat6
lrwxrwxrwx    1 root root     15 Dec 27 13:00 .jenkins -> /data01/jenkins
lrwxrwxrwx    1 root root     23 Dec 27 11:28 lib -> /usr/share/java/tomcat6
lrwxrwxrwx    1 root root     16 Dec 27 11:28 logs -> /var/log/tomcat6
lrwxrwxrwx    1 root root     23 Dec 27 11:28 temp -> /var/cache/tomcat6/temp
lrwxrwxrwx    1 root root     24 Dec 27 11:28 webapps -> /var/lib/tomcat6/webapps
lrwxrwxrwx    1 root root     23 Dec 27 11:28 work -> /var/cache/tomcat6/work
[root@lx08 tomcat6]# pwd
/usr/share/tomcat6

[root@lx08 tomcat6]# export JENKINS_HOME=http://localhost:8080/jenkins
[root@lx08 tomcat6]# java -jar /usr/share/tomcat6/webapps/jenkins/WEB-INF/lib/jenkins-core-1.495.jar  "TestJob" echo hello
hello


0

根据我阅读的文档和上面的几个示例,Jenkins使用您的Tomcat用户的主目录并在该文件夹中搜索.jenkins。确保将Tomcat用户的主目录设置为所需的值,例如/ opt / apache / tomcat,并在该文件夹中创建一个指向您Jenkins文件夹所在位置的.jenkins符号链接。

ln -s /path/to/jenkins_home /opt/apache/tomcat/.jenkins
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.