如何在Ubuntu上安装Jenkins


Jenkins是一个强大的应用程序,允许持续集成和持续交付项目,无论您使用什么平台。它是一个开源软件,可以处理任何类型的构建或持续集成。您可以将Jenkins与许多测试和部署技术集成。本文介绍了“如何在Ubuntu上安装Jenkins”。

要添加Jenkins PPA到Ubuntu,请使用以下命令:

$ wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.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

要安装Jenkins,请使用以下命令:

$ sudo apt-get install jenkins

示例输出应如下所示:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
   libterm-readkey-perl linux-headers-4.4.0-31 linux-headers-4.4.0-31-generic
   linux-image-4.4.0-31-generic linux-image-extra-4.4.0-31-generic
   linux-signed-image-4.4.0-31-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
   daemon
The following NEW packages will be installed:
   daemon jenkins
0 upgraded, 2 newly installed, 0 to remove and 28 not upgraded.
Need to get 69.9 MB of archives.
After this operation, 70.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu xenial/universe amd64 daemon amd64 0.6.4-1 [98.2 kB]
.............................................................................................

要设置Jenkins的端口号,请使用以下命令:

$ sudo nano etc/default/jenkins

示例输出应如下所示:

# defaults for jenkins continuous integration server

# pulled in from the init script; makes things easier.
NAME=jenkins

# location of java
JAVA=/usr/bin/java

# arguments to pass to java
JAVA_ARGS="-Djava.awt.headless=true" # Allow graphs etc. to work even when an $
#JAVA_ARGS="-Xmx256m"
#JAVA_ARGS="-Djava.net.preferIPv4Stack=true" # make jenkins listen on IPv4 addr$

PIDFILE=/var/run/$NAME/$NAME.pid

# user and group to be invoked as (default to jenkins)
JENKINS_USER=$NAME
JENKINS_GROUP=$NAME
........................................................................

现在搜索`HTTP_PORT=8080`并替换为`HTTP_PORT=8081`,如下所示:

# port for HTTP connector (default 8080; disable with -1)
HTTP_PORT=8081

现在保存并退出文件。要重启Jenkins,请使用以下命令:

$ sudo service jenkins restart

复制以下URL并粘贴到您喜欢的浏览器中:

https://127.0.0.1:8081/

示例输出应如下所示:

使用以下命令查找管理员密码,如下所示:

$ sudo nano /var/lib/jenkins/secrets/initialAdminPassword

复制密码并粘贴到您的浏览器中。现在单击继续按钮。示例输出如下所示:

现在单击`安装推荐插件`,将显示以下屏幕:

安装过程完成后,将出现以下屏幕,用于创建第一个管理员用户,如下所示:

填写所需信息,然后单击保存并完成按钮。现在将显示以下屏幕:

现在单击`开始使用Jenkins`,将显示以下屏幕:

在本文中,我们学习了如何在Ubuntu上安装Jenkins。在我们的下一篇文章中,我们将介绍更多基于Linux的技巧和提示。敬请关注!

更新于:2020年1月22日

浏览量:592

启动你的职业生涯

通过完成课程获得认证

开始
广告