文档章节

Installing Jenkins on Ubuntu

openthings
 openthings
发布于 2015/12/09 10:44
字数 833
阅读 57
收藏 0

On Debian-based distributions, such as Ubuntu, you can install Jenkins through apt-get.

Recent versions are available in an apt repository. Older but stable LTS versions are in this apt repository.

You need to have a JDK and JRE installed. openjdk-7-jre and openjdk-7-jdk are suggested. As of 2011-08 gcj is known to be problematic - see https://issues.jenkins-ci.org/browse/JENKINS-743.

Please make sure to back up any current Hudson or Jenkins files you may have.

Installation

wget -q -O - https://jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ 
    > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins

Upgrade

Once installed like this, you can update to the later version of Jenkins (when it comes out) by running the following commands:

sudo apt-get update
sudo apt-get install jenkins

(aptitude or apt-get doesn't make any difference.)

What does this package do?

  • Jenkins will be launched as a daemon up on start. See /etc/init.d/jenkins for more details.

  • The 'jenkins' user is created to run this service.

  • Log file will be placed in /var/log/jenkins/jenkins.log. Check this file if you are troubleshooting Jenkins.

  • /etc/default/jenkins will capture configuration parameters for the launch like e.g JENKINS_HOME

  • By default, Jenkins listen on port 8080. Access this port with your browser to start configuration.

If your /etc/init.d/jenkins file fails to start jenkins, edit the /etc/default/jenkins to replace the line
HTTP_PORT=8080

by

HTTP_PORT=8081

Here, 8081 was chosen but you can put another port available.

Deploying on Ubuntu in a cloud (EC2, HP Cloud, OpenStack)

The Ubuntu Jenkins maintainer also maintains the Juju charm deployment/management script for deployment in clouds. It's designed to make it easy to deploy a master with multiple slaves:

juju deploy jenkins
juju deploy -n 5 jenkins-slave
juju add-relation jenkins jenkins-slave

The default password for the 'admin' account will be auto-generated. You can set it using:

juju set jenkins password=mypassword

Always change it this way - this account is used by the charm to manage slave configuration. Then feel free to expose your jenkins master:

juju expose jenkins

Using Linux iptables for port 80 -> 8080

  • This enables port forwarding of traffic between ports 80 and 8080. You can keep Jenkins on the default port 8080 and access it with a normal url without installing anything extra.

  • sudo nano /etc/rc.local

  • Then add the following just before the exit 0

#Requests from outside
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080
#Requests from localhost
iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 80 -j REDIRECT --to-ports 8080

Now reboot or run sudo /etc/rc.local to enable port forwarding. Additional info: https://gist.github.com/m5m1th/6870a54717c0387468c3

Setting up an Apache Proxy for port 80 -> 8080

  • This configuration will setup Apache2 to proxy port 80 to 8080 so that you can keep Jenkins on 8080.

  • sudo aptitude install apache2

  • sudo a2enmod proxy

  • sudo a2enmod proxy_http

do not do this next command if you already have virtual hosting setup that depends on the default site. See my comment below - danapsimer
  • sudo a2dissite default

If you get ERROR: Site default does not exist! then try this instead:
  • sudo a2dissite 000-default

And if all else fails just have a look if there is a default site set up at all:

  • ls  /etc/apache2/sites-enabled/

  • Create a file called jenkins.conf in /etc/apache2/sites-available

<VirtualHost *:80>
	ServerAdmin webmaster@localhost
	ServerName ci.company.com
	ServerAlias ci
	ProxyRequests Off	<Proxy *>
		Order deny,allow
		Allow from all	</Proxy>
	ProxyPreserveHost on
	ProxyPass / http://localhost:8080/ nocanon
	AllowEncodedSlashes NoDecode</VirtualHost>
  • sudo a2ensite jenkins

  • sudo apache2ctl restart

Setting up an Nginx Proxy for port 80 -> 8080

This configuration will setup Nginx to proxy port 80 to 8080 so that you can keep Jenkins on 8080. Instructions originally found in a GitHub Gist from rdegges: https://gist.github.com/913102

  • Install Nginx.

    sudo aptitude -y install nginx
  • Remove default configuration.

    cd /etc/nginx/sites-available
    sudo rm default ../sites-enabled/default
  • Create new configuration for Jenkins. This example uses cat, but you can use your favorite text editor. Make sure to replace 'ci.yourcompany.com' with your domain name.
    Note: Sometimes your permissions (umask, etc) might be setup such that this won't work. Create the file somewhere else then copy it into place if you run into that problem.

    sudo cat > jenkins
    upstream app_server {
        server 127.0.0.1:8080 fail_timeout=0;
    }
    
    server {
        listen 80;
        listen [::]:80 default ipv6only=on;
        server_name ci.yourcompany.com;
    
        location / {
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_redirect off;        if (!-f $request_filename) {
                proxy_pass http://app_server;            break;
            }
        }
    }
    ^D # Hit CTRL + D to finish writing the file
  • Link your configuration from sites-available to sites-enabled:

    sudo ln -s /etc/nginx/sites-available/jenkins /etc/nginx/sites-enabled/
  • Restart Nginx

    sudo service nginx restart

Where to go from here?


本文转载自:https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu

openthings

openthings

粉丝 328
博文 1155
码字总数 851078
作品 1
东城
架构师
私信 提问
在 ubuntu 中愉快的安装 Jenkins

这篇文章详细的记录了在 ubuntu 中安装 Jenkins 的一步又一步,因为找了很多 Linux 下安装 Jenkins 的教程,不是很满意 所以决定自己写一篇以备后用(终于让我找到了Java 不用去官网下载的方法...

易墨
2018/08/02
0
0
React Native 【学习总结】-【Jenkins集成】

简述 Jenkins是一个持续集成工具,它本身有很丰富的插件提供使用,方便持续集成,为开发省时省力,下面是项目中对新的RN项目做的持续集成例子,通过该例子学会如何使用jenkins。 Jenkins安装...

Pape
2018/05/18
0
0
ubuntu 16.04 安装 Jenkins

安装方法很简单: 如果在执行 中出现如下报错: 说明Jenkins没有在/usr/bin下找到jdk相关文件。可以通过创建软链接解决此问题。 在执行就算是安装完了。 浏览器输入“address:8080”,会显示...

Kampfer
01/31
174
0
利用Jenkins+Gitlab搭建持续集成(CI)环境

这次实习的任务之一就是搭建一个持续集成(Continuous Integration)环境。 我们选择Jenkins作为持续集成工具,其优点是提供web GUI配置界面,方便配置,还可以安装很多第三方插件(plugin)进...

mingle
2015/08/24
1K
0
Continuous Integration

-- 几个月前的学习笔记,懒得再翻译回来了 Continuous Integration Continuous Integration Purpose & Main Goals Enviroment Infomation CentOS root @ qazwsx%1984416ssh work dir : Config......

pillsilly
2016/08/25
71
0

没有更多内容

加载失败,请刷新页面

加载更多

Spring Boot Actuator监控使用详解

在企业级应用中,学习了如何进行SpringBoot应用的功能开发,以及如何写单元测试、集成测试等还是不够的。在实际的软件开发中还需要:应用程序的监控和管理。SpringBoot的Actuator模块实现了应...

程序新视界
15分钟前
4
0
JDBC+C3P0+DBCP 基本使用

1.概述 这篇文章主要说了JDBC的基本使用,包括Statement,PreparedStatement,JDBC的连接,Mysql创建用户创建数据表,C3P0的连接与配置,DBCP的连接与配置. 2.mysql的处理 这里的JDBC使用Mysql作为...

Blueeeeeee
今天
7
0
MVC Linux下开发及部署

linux使用的是 Ubuntu 64 位 18.04.2 LTS 首先复制C:\Program Files (x86)\Embarcadero\Studio\20.0\PAServer 下 LinuxPAServer20.0.tar.gz 到 linux 目录下 运行链接编译程序 delphi环境配置......

苏兴迎
今天
11
0
3.控件及其属性

1.文本 2.按钮

横着走的螃蟹
今天
9
0
安装Genymotion模拟器慢的解决方案

第一步点击下载, C:\Users\Administrator\AppData\Local\Genymobile\genymotion.log 中搜索 ova 会发现这个文件 使用迅雷下载即可. 在 虚拟机中导入这个.ova 文件 即可安装...

chenhongjiang
今天
6
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部