ubuntu设置jenkins开机自动启动

来源:互联网 发布:鸡兔同笼c语言编程答案 编辑:程序博客网 时间:2024/04/29 14:21

本来我没有找到类似于gerrit的启动脚本

但是万能的google告诉了我,人家官网上提供了……

https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+as+a+Unix+daemon

以及

https://wiki.jenkins-ci.org/display/JENKINS/JenkinsLinuxStartupScript

我觉得可以参考下面这种方法:

Java Service Wrapper

The The Java Service wrapper is a wrapper that works both on Unix and Windows. It requires some set up but when it is setup it can be used as any other unix service (like start/stop).

This example will install a Jenkins instance in /home/jenkins on a debian machine. The Jenkins configuration is stored in /home/jenkins/data. Jenkins will be running on port 8070 and as the jenkins user.

  1. Select and download a JSW package from the JSW wrapper download page.
  2. Unpack the package into the /home/jenkins path.
  3. Create /home/jenkins/tmp as the temporary directory for JSW.
  4. Download the jenkins.war file into /home/jenkins/lib.
    • If you have plugins that you would like to use, download them into /home/jenkins/data/plugins.
  5. Copy the /home/jenkins/src/conf/wrapper.conf.in to /home/jenkins/conf/wrapper.conf and change the below configuration properties in the file.
    wrapper.java.classpath.1=../lib/jenkins.warwrapper.java.classpath.2=../lib/wrapper.jarwrapper.java.additional.1=-DJENKINS_HOME=../datawrapper.java.additional.2=-Djava.io.tmpdir=../tmpwrapper.java.additional.3=-server# Set directly the time zone of the JVM, by setting this we do not rely on the time zone of the server.# Uncomment the following line if needed.# wrapper.java.additional.4=-Duser.timezone=America/Los_Angeleswrapper.app.parameter.1=Mainwrapper.app.parameter.2=--httpPort=8070wrapper.ping.timeout=300wrapper.jvm_exit.timeout=60wrapper.console.title=Jenkins Continuous build server
  6. Verify the wrapper configuration by starting Jenkins through /home/jenkins/bin/testwrapper console. Jenkins should be accessible through http://localhost:8070, if not check the console output for errors.
  7. Copy the /home/jenkins/src/bin/sh.script.in to /etc/init.d/jenkins and change the below configuration properties in the file.
    APP_NAME="Jenkins"APP_LONG_NAME="Jenkins Continuous build server"WRAPPER_CMD="/home/jenkins/bin/wrapper"WRAPPER_CONF="/home/jenkins/conf/wrapper.conf"PIDDIR="/home/jenkins/bin"RUN_AS_USER=jenkins
  8. Verify installation by starting the daemon through /etc/init.d/jenkins start. Make sure that /etc/init.d/jenkins has the correct permissions; normally 755 is ok for this.


照着上面的改的,RUN_AS_USER我就用的自己的用户

然后系统启动起来之后jenkins的服务启动的较慢,可能要等一分钟。

不过,自动启动是验证过了OK了,可以用了

0 0
原创粉丝点击