Fork me on GitHub
Suzf  Blog

How To Install Jenkins on Ubuntu 16.04

License: Attribution-NonCommercial-ShareAlike 4.0 International

本文出自 Suzf Blog。 如未注明,均为 SUZF.NET 原创。

转载请注明:http://suzf.net/post/1202

介绍

Jenkins是一个用Java编写的开源持续集成工具。在与Oracle发生争执后,项目从Hudson项目复刻。 Jenkins提供了软件开发的持续集成服务。它运行在Servlet容器中(例如Apache Tomcat)。它支持软件配置管理(SCM)工具(包括AccuRev SCMCVSSubversionGitPerforceClearcase和和RTC),可以执行基于Apache AntApache Maven的项目,以及任意的Shell脚本和Windows批处理命令。Jenkins的主要开发者是川口耕介。[2]Jenkins是在MIT许可证下发布的自由软件[3] 可以通过各种手段触发构建。例如提交给版本控制系统时被触发,也可以通过类似Cron的机制调度,也可以在其他的构建已经完成时,还可以通过一个特定的URL进行请求。

系统要求

Minimum Recommended Configuration: Java 7 256MB free memory 1GB+ free disk space Recommended Configuration for Small Team: Java 8 1GB+ free memory 50GB+ free disk space

安装

Debian/Ubuntu

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

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

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

# Install OpenJDK
# -- http://openjdk.java.net/install/
# -- The openjdk-8-jre package contains just the Java Runtime Environment. 
# -- If you want to develop Java programs then please install the openjdk-8-jdk package.
sudo apt-get install openjdk-8-jre openjdk-8-jdk

# make sure the jdk install success
java -version
openjdk version "1.8.0_111"
OpenJDK Runtime Environment (build 1.8.0_111-8u111-b14-2ubuntu0.16.04.2-b14)
OpenJDK 64-Bit Server VM (build 25.111-b14, mixed mode)

# now jdk installed, Let's add JAVA_HOME Env variable
cat > /etc/profile.d/java-8-openjdk.sh < < EOF
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
PATH=\$JAVA_HOME/bin:\$PATH
export JAVA_HOME PATH
EOF

source /etc/profile.d/java-8-openjdk.sh

This package installation will:

  • Setup Jenkins as a daemon launched on start. See /etc/init.d/jenkins for more details.
  • Create a jenkins user to run this service.
  • Direct console log output to the file /var/log/jenkins/jenkins.log. Check this file if you are troubleshooting Jenkins.
  • Populate /etc/default/jenkins with configuration parameters for the launch, e.g JENKINS_HOME
  • Set Jenkins to listen on port 8080. Access this port with your browser to start configuration.
  • INFO
  • If your /etc/init.d/jenkins file fails to start Jenkins, edit the /etc/default/jenkins to replace the line ----HTTP_PORT=8080---- with ----HTTP_PORT=8081---- Here, "8081" was chosen but you can put another port available.
安装后(安装向导)

Create Admin User and Password for Jenkins

Jenkins最初配置为在首次启动时是安全的。 如果没有用户名和密码,Jenkins将无法再访问,并且开放端口有限。 在初始运行Jenkins期间,将生成一个安全令牌并将其打印在控制台日志中:

*************************************************************

Jenkins initial setup is required. An admin user has been created and a password generated.
Please use the following password to proceed to installation:

ae09a2a86xxx4b10952c70894d63xxxx

This may also be found at: /var/lib/jenkins/secrets/initialAdminPassword

*************************************************************

上面每个平台的安装说明包括您可以找到此日志输出的默认位置。 首次打开Jenkins UI时,必须在“安装向导”中输入此令牌。 如果您跳过安装向导中的用户创建步骤,则此令牌也将用作用户admin的默认密码。

初始插件安装

安装向导还将安装此Jenkins服务器的初始插件。 推荐的可用插件集是基于最常见的用例。 您可以在安装向导期间添加更多内容,或者根据需要稍后安装。 [0] https://jenkins.io/doc/book/getting-started/installing/ [1] https://zh.wikipedia.org/wiki/Jenkins_(%E8%BD%AF%E4%BB%B6)

Jenkins ver. 2.32.1

「一键投喂 软糖/蛋糕/布丁/牛奶/冰阔乐!」

Suzf Blog

(๑>ڡ<)☆ 谢谢 ~

使用微信扫描二维码完成支付