Jenkins的介绍与安装
Jenkins是什么
Jenkins是一款开源 CI&CD 软件,用于自动化各种任务,包括构建、测试和部署软件。
Jenkins 支持各种运行方式,可通过系统包、Docker 或者通过一个独立的 Java 程序。
安装Jenkins
Docker方式
1 | # 8080:控制台端口 |
可通过查看日志查看初始密码:
1 | $ docker logs -f jenkins |
WAR包方式
Jenkins的Web应用程序ARchive(WAR)文件版本可以安装在任何支持Java的操作系统或平台上。
要下载并运行Jenkins的WAR文件版本,请执行以下操作:
将最新的稳定Jenkins WAR包 下载到您计算机上的相应目录。
在下载的目录内打开一个终端/命令提示符窗口到。
运行命令
java -jar jenkins.war
,也可以指定端口:java -jar jenkins.war --httpPort=9090
浏览http://localhost:8080并等到*Unlock Jenkins*页面出现。
Notes:
- 不像在Docker中下载和运行有Blue Ocean的Jenkins,这个过程不会自动安装Blue Ocean功能, 这将分别需要在jenkins上通过 Manage Jenkins > Manage Plugins安装。 在Getting started with Blue Ocean有关于安装Blue Ocean的详细信息 。.
- 您可以通过
--httpPort
在运行java -jar jenkins.war
命令时指定选项来更改端口。例如,要通过端口9090访问Jenkins,请使用以下命令运行Jenkins:java -jar jenkins.war --httpPort=9090
Linux二进制
Debian/Ubuntu
在基于Debian的发行版(如Ubuntu)上,您可通过apt
安装Jenkins
每 12 周从常规版本流中选择一个LTS(长期支持)版本作为该时间段的稳定版本。它可以从debian-stable
apt 存储库安装。
1 | $ curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo tee \ |
安装这个软件包将会:
- 将Jenkins设置为启动时启动的守护进程。查看
/etc/init.d/jenkins
获取更多细节 - 创建一个’
jenkins
‘用户来运行此服务 - 直接将控制台日志输出到文件
/var/log/jenkins/jenkins.log
。如果您正在解决Jenkins问题,请检查此文件 /etc/default/jenkins
为启动填充配置参数,例如JENKINS_HOME
- 将Jenkins设置为在端口8080上进行监听。使用浏览器访问此端口以开始配置
如果你的
/etc/init.d/jenkins
文件无法启动Jenkins,编辑/etc/default/jenkins
, 修改----HTTP_PORT=8080----
为----HTTP_PORT=8081----
在这里,“8081”也可被换为其他可用端口。
Fedora
1 | sudo wget -O /etc/yum.repos.d/jenkins.repo \ |
Start Jenkins
Register the Jenkins service with the command:
1 | sudo systemctl daemon-reload |
You can start the Jenkins service with the command:
1 | sudo systemctl start jenkins |
You can check the status of the Jenkins service using the command:
1 | sudo systemctl status jenkins |
If everything has been set up correctly, you should see an output like this:
1 | Loaded: loaded (/etc/rc.d/init.d/jenkins; generated) |
Red Hat / CentOS
每 12 周从常规版本流中选择一个LTS(长期支持)版本作为该时间段的稳定版本。它可以从debian-stable
apt 存储库安装。
1 | sudo wget -O /etc/yum.repos.d/jenkins.repo \ |
Start Jenkins
You can start the Jenkins service with the command:
1 | sudo systemctl start jenkins |
You can check the status of the Jenkins service using the command:
1 | sudo systemctl status jenkins |
If everything has been set up correctly, you should see an output like this:
1 | Loaded: loaded (/etc/rc.d/init.d/jenkins; generated) |
简单的初始配置
浏览器访问http://localhost:8080/,并输入安装后得到的密码
紧接着有两个选项
- 安装建议的插件 - 安装推荐的一组插件,这些插件基于最常见的用例.(新手推荐)
- 选择要安装的插件 - 选择安装的插件集。当你第一次访问插件选择页面时,默认选择建议的插件。
创建第一个管理员用户
安装好插件后,会提示创建用户:
Jenkins的介绍与安装