ubuntu設置jenkins開機自動啓動

本來我沒有找到類似於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.war
    wrapper.java.classpath.2=../lib/wrapper.jar
    
    wrapper.java.additional.1=-DJENKINS_HOME=../data
    wrapper.java.additional.2=-Djava.io.tmpdir=../tmp
    wrapper.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_Angeles
    
    wrapper.app.parameter.1=Main
    wrapper.app.parameter.2=--httpPort=8070
    
    wrapper.ping.timeout=300
    wrapper.jvm_exit.timeout=60
    
    wrapper.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了,可以用了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章