红联Linux门户
Linux帮助

Ubuntu安装jenkins

发布时间:2016-06-12 09:53:32来源:linux网站作者:Miya不是小怪兽

首先在jenkins官网上下载jenkins.war包。下载后,将war包上传到jerry/webapps目录下,并在此目录中新建文件jenkins.xml,文件完整内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">

<!-- ========================================
Configure and deploy the test web application in $(jetty.home)/webapps/test

Note. If this file did not exist or used a context path other that /test
then the default configuration of jetty.xml would discover the test
webapplication with a WebAppDeployer.  By specifying a context in this
directory, additional configuration may be specified and hot deployments
detected.
======================================== -->

<Configure id="jenkinsWebapp" class="org.eclipse.jetty.webapp.WebAppContext">

<!-- - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- Required minimal context configuration :-->
<!--  + contextPath  -->
<!--  + war OR resourceBase  -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - -->
<Set name="contextPath">/jenkins</Set>
<Set name="war"><Property name="jetty.home" default="."/>/webapps/jenkins.war</Set>

<!-- - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- Optional context configuration  -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - -->
<Set name="extractWAR">true</Set>
<Set name="copyWebDir">false</Set>
<Set name="defaultsDescriptor"><Property name="jetty.home" default="."/>/etc/webdefault.xml</Set>
<!--Set name="overrideDescriptor"><Property name="jetty.webapps" default="."/>/test.d/override-web.xml</Set-->

<!-- Enable WebSocket container -->
<Call name="setAttribute">
<Arg>org.eclipse.jetty.websocket.jsr356</Arg>
<Arg type="Boolean">true</Arg>
</Call>

<Set name="gzipHandler">
<New class="org.eclipse.jetty.server.handler.gzip.GzipHandler">
<Set name="minGzipSize">2048</Set> 
</New>
</Set>

<!-- Set Caching Classloader that improves performance on resource searching webapps -->
<!--
<Set name="classLoader">
<New class="org.eclipse.jetty.webapp.CachingWebAppClassLoader">
<Arg><Ref refid="testWebapp"/></Arg>
</New>
</Set>
-->

<!-- Enable symlinks
<Call name="addAliasCheck">
<Arg><New class="org.eclipse.jetty.server.handler.AllowSymLinkAliasChecker"/></Arg>
</Call>
-->

<!-- virtual hosts
<Set name="virtualHosts">
<Array type="String">
<Item>www.MyVirtualDomain.com</Item>
<Item>m.MyVirtualDomain.com</Item>
<Item>*.OtherVirtualDomain.com</Item>
<Item>@ConnectorName</Item>
<Item>localhost</Item>
<Item>127.0.0.1</Item>
</Array>
</Set>
-->

<!-- disable cookies
<Get name="sessionHandler">
<Get name="sessionManager">
<Set name="usingCookies" type="boolean">false</Set>
</Get>
</Get>
-->

<Get name="securityHandler">
<Set name="loginService">
<New class="org.eclipse.jetty.security.HashLoginService">
<Set name="name">jenkins Realm</Set>
<Set name="config"><SystemProperty name="jetty.base" default="."/>/etc/realm.properties</Set>
<!-- To enable reload of realm when properties change, uncomment the following lines -->
<!-- changing refreshInterval (in seconds) as desired-->
<!--
<Set name="refreshInterval">5</Set>
<Call name="start"></Call>
-->
</New>
</Set>
<Set name="authenticator">
<New class="org.eclipse.jetty.security.authentication.FormAuthenticator">
<Set name="alwaysSaveUri">true</Set>
</New>
</Set>
<Set name="checkWelcomeFiles">true</Set>
</Get>

<!-- Non standard error page mapping -->
<!--
<Get name="errorHandler">
<Call name="addErrorPage">
<Arg type="int">500</Arg>
<Arg type="int">599</Arg>
<Arg type="String">/dump/errorCodeRangeMapping</Arg>
</Call>
</Get>
-->

<!-- Add context specific logger
<Call name="insertHandler">
<Arg>
<New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler">
<Set name="requestLog">
<New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
<Set name="filename"><Property name="jetty.logs" default="./logs"/>/test-yyyy_mm_dd.request.log</Set>
<Set name="filenameDateFormat">yyyy_MM_dd</Set>
<Set name="append">true</Set>
<Set name="LogTimeZone">GMT</Set>
</New>
</Set>
</New>
</Arg>
</Call>
-->

</Configure>


注意修改其中jenkins war包的路径。然后cd 到/etc/jetty目录,执行java -jar start.jar 命令启动jetty。启动成功后,访问jenkins:

Ubuntu安装jenkins


注意,这里可能需要修改jenkins工作的主目录,后续因为编译任务增多,默认的目录可能不适合。按照如下步骤修改:

使用vi /etc/profile 命令来编辑该文件,在该文件末尾添加:
export JENKINS_HOME=/apphome/jenkins
保存后退出,并在shell中执行source /etc/profile。
重启jetty。

Ubuntu安装jenkins


本文永久更新地址:http://www.linuxdiyf.com/linux/21442.html