mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-25 23:11:02 +08:00
Merge pull request #5459 from ictlyh/master
Translated tech/20161125 How to Install Jenkins Automation Server wit…
This commit is contained in:
commit
3c87eb1390
@ -1,266 +0,0 @@
|
||||
ictlyh 接手 willcoderwang 翻译
|
||||
How to Install Jenkins Automation Server with Apache on Ubuntu 16.04
|
||||
============================================================
|
||||
|
||||
|
||||
Jenkins is an automation server forked from the Hudson project. Jenkins is a server based application running in a Java servlet container, it has support for many SCM (Source Control Management) software systems including Git, SVN, and Mercurial. Jenkins provides hundreds of plugins to automate your project. Jenkins created by Kohsuke Kawaguchi, first released in 2011 under MIT License, and it's free software.
|
||||
|
||||
In this tutorial, I will show you how to install the latest Jenkins version on Ubuntu Server 16.04\. We will run Jenkins on our own domain name, and we will to install and configure Jenkins to run under the apache web server with the reverse proxy for Jenkins.
|
||||
|
||||
### Prerequisite
|
||||
|
||||
* Ubuntu Server 16.04 - 64bit
|
||||
* Root Privileges
|
||||
|
||||
### Step 1 - Install Java OpenJDK 7
|
||||
|
||||
Jenkins is based on Java, so we need to install Java OpenJDK version 7 on the server. In this step, we will install Java 7 from a PPA repository which we will add first.
|
||||
|
||||
By default, Ubuntu 16.04 ships without the python-software-properties package for managing PPA repositories, so we must install this package first. Install python-software-properties with apt command.
|
||||
|
||||
apt-get install python-software-properties
|
||||
|
||||
Next, add Java PPA repository to the server.
|
||||
|
||||
add-apt-repository ppa:openjdk-r/ppa
|
||||
Just Press ENTER
|
||||
|
||||
Update the Ubuntu repository and install the Java OpenJDK with apt command.
|
||||
|
||||
apt-get update
|
||||
apt-get install openjdk-7-jdk
|
||||
|
||||
Verify the installation by typing the command below:
|
||||
|
||||
java -version
|
||||
|
||||
and you will get the Java version that is installed on the server.
|
||||
|
||||
[
|
||||
![Install Java 7 openJDK on Ubuntu 16.04](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/1.png)
|
||||
][9]
|
||||
|
||||
### Step 2 - Install Jenkins
|
||||
|
||||
Jenkins provides an Ubuntu repository for the installation packages and we will install Jenkins from this repository.
|
||||
|
||||
Add Jenkins key and repository to the system with the command below.
|
||||
|
||||
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
|
||||
echo 'deb https://pkg.jenkins.io/debian-stable binary/' | tee -a /etc/apt/sources.list
|
||||
|
||||
Update the repository and install Jenkins.
|
||||
|
||||
apt-get update
|
||||
apt-get install jenkins
|
||||
|
||||
When the installation is done, start Jenkins with this systemctl command.
|
||||
|
||||
systemctl start jenkins
|
||||
|
||||
Verify that Jenkins is running by checking the default port used by Jenkins (port 8080). I will check it with the netstat command below:
|
||||
|
||||
netstat -plntu
|
||||
|
||||
Jenkins is installed and running on port 8080.
|
||||
|
||||
[
|
||||
![Jenkins has been installed on port 8080](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/2.png)
|
||||
][10]
|
||||
|
||||
### Step 3 - Install and Configure Apache as Reverse Proxy for Jenkins
|
||||
|
||||
In this tutorial we will run Jenkins behind an apache web server, we will configure apache as the reverse proxy for Jenkins. First I will install apache and enable some require modules, and then I'll create the virtual host file with domain name my.jenkins.id for Jenkins. Please use your own domain name here and replace it in all config files wherever it appears.
|
||||
|
||||
Install apache2 web server from Ubuntu repository.
|
||||
|
||||
apt-get install apache2
|
||||
|
||||
When the installation is done, enable the proxy and proxy_http modules so we can configure apache as frontend server/reverse proxy for Jenkins.
|
||||
|
||||
a2enmod proxy
|
||||
a2enmod proxy_http
|
||||
|
||||
Next, create a new virtual host file in the sites-available directory.
|
||||
|
||||
cd /etc/apache2/sites-available/
|
||||
vim jenkins.conf
|
||||
|
||||
Paste virtual host configuration below.
|
||||
|
||||
```
|
||||
<Virtualhost *:80>
|
||||
ServerName my.jenkins.id
|
||||
ProxyRequests Off
|
||||
ProxyPreserveHost On
|
||||
AllowEncodedSlashes NoDecode
|
||||
|
||||
<Proxy http://localhost:8080/*>
|
||||
Order deny,allow
|
||||
Allow from all
|
||||
</Proxy>
|
||||
|
||||
ProxyPass / http://localhost:8080/ nocanon
|
||||
ProxyPassReverse / http://localhost:8080/
|
||||
ProxyPassReverse / http://my.jenkins.id/
|
||||
</Virtualhost>
|
||||
```
|
||||
|
||||
Save the file. Then activate the Jenkins virtual host with the a2ensite command.
|
||||
|
||||
a2ensite jenkins
|
||||
|
||||
Restart Apache and Jenkins.
|
||||
|
||||
systemctl restart apache2
|
||||
systemctl restart jenkins
|
||||
|
||||
Check that port 80 and 8000 are in use by Jenkins and Apache.
|
||||
|
||||
netstat -plntu
|
||||
|
||||
[
|
||||
![Check that Apache and Jenkins are running](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/3.png)
|
||||
][11]
|
||||
|
||||
### Step 4 - Configure Jenkins
|
||||
|
||||
Jenkins is running on the domain name 'my.jenkins.id'. Open your web browser and type in the URL. You will get the screen that requests you to enter the initial admin password. A password has been generated by Jenkins already, so we just need to show and copy the results to the password box.
|
||||
|
||||
Show initial admin password Jenkins with cat command.
|
||||
|
||||
cat /var/lib/jenkins/secrets/initialAdminPassword
|
||||
|
||||
a1789d1561bf413c938122c599cf65c9
|
||||
|
||||
[
|
||||
![Get the Jenkins admin password](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/4.png)
|
||||
][12]
|
||||
|
||||
Paste the results to the screen and click '**Continue**'.
|
||||
|
||||
[
|
||||
![Jenkins Installation and Configuration](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/5.png)
|
||||
][13]
|
||||
|
||||
Now we should install some plugins in Jenkins to get a good foundation for later use. Choose '**Install Suggested Plugins**', click on it.
|
||||
|
||||
[
|
||||
![Install jenkins Plugins](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/6.png)
|
||||
][14]
|
||||
|
||||
Jenkins plugins installations in progress.
|
||||
|
||||
[
|
||||
![Jenkins plugins get installed](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/7.png)
|
||||
][15]
|
||||
|
||||
After plugin installation, we have to create a new admin password. Type in your admin username, password, email etc. and click on '**Save and Finish**'.
|
||||
|
||||
[
|
||||
![Create Jenkins admin account](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/8.png)
|
||||
][16]
|
||||
|
||||
Click start and start using Jenkins. You will be redirected to the Jenkins admin dashboard.
|
||||
|
||||
[
|
||||
![Get redirected to the admin dashboard](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/9.png)
|
||||
][17]
|
||||
|
||||
Jenkins installation and Configuration finished successfully
|
||||
|
||||
[
|
||||
![The Jenkins admin dashboard](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/10.png)
|
||||
][18]
|
||||
|
||||
### Step 5 - Jenkins Security
|
||||
|
||||
From the Jenkins admin dashboard, we need to configure the standard security settings for Jenkins, click on '**Manage Jenkins**' and then '**Configure Global Security**'.
|
||||
|
||||
[
|
||||
![Jenkins Global Security Settings](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/11.png)
|
||||
][19]
|
||||
|
||||
Jenkins provides several authorization methods in the '**Access Control**' section. I select '**Matrix-based Security**' to be able to control all user privileges. Enable the admin user at the box '**User/Group**' and click **add**. Give the admin all privileges by **checking all options**, and give the anonymous just read permissions. Now Click '**Save**'.
|
||||
|
||||
[
|
||||
![Configure Jenkins Permissions](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/12.png)
|
||||
][20]
|
||||
|
||||
You will be redirected to the dashboard, and if there is login option, just type your admin user and password.
|
||||
|
||||
### Step 6 - Testing a simple automation job
|
||||
|
||||
In this section, I just want to test a simple job for the Jenkins server. I will create a simple job for testing Jenkins and to find out the server load with the top command.
|
||||
|
||||
From the Jenkins admin dashboard, click '**Create New Job**'.
|
||||
|
||||
[
|
||||
![Create a new Job in Jenkins](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/13.png)
|
||||
][21]
|
||||
|
||||
Enter the job name, I'll use 'Checking System' here, select '**Freestyle Project**' and click '**OK**'.
|
||||
|
||||
[
|
||||
![Configure new Jenkins Job](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/14.png)
|
||||
][22]
|
||||
|
||||
Go to the '**Build**' tab. On the '**Add build step**', select the option '**Execute shell**'.
|
||||
|
||||
Type in the command below into the box.
|
||||
|
||||
top -b -n 1 | head -n 5
|
||||
|
||||
Click '**Save**'.
|
||||
|
||||
[
|
||||
![Start a Jenkins Job](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/15.png)
|
||||
][23]
|
||||
|
||||
Now you are on the job page of the job 'Project checking system'. Click '**Build Now**' to execute the job 'checking system'.
|
||||
|
||||
After the job has been executed, you will see the '**Build History**', click on the first job to see the results.
|
||||
|
||||
Here are the results from the job executed by Jenkins.
|
||||
|
||||
[
|
||||
![Build and run a Jenkins Job](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/16.png)
|
||||
][24]
|
||||
|
||||
Jenkins installation with Apache web server on Ubuntu 16.04 completed successfully.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/
|
||||
|
||||
作者:[Muhammad Arul ][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 组织编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://twitter.com/howtoforgecom
|
||||
[1]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#prerequisite
|
||||
[2]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#step-install-java-openjdk-
|
||||
[3]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#step-install-jenkins
|
||||
[4]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#step-install-and-configure-apache-as-reverse-proxy-for-jenkins
|
||||
[5]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#step-configure-jenkins
|
||||
[6]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#step-jenkins-security
|
||||
[7]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#step-testing-a-simple-automation-job
|
||||
[8]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#reference
|
||||
[9]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/1.png
|
||||
[10]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/2.png
|
||||
[11]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/3.png
|
||||
[12]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/4.png
|
||||
[13]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/5.png
|
||||
[14]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/6.png
|
||||
[15]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/7.png
|
||||
[16]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/8.png
|
||||
[17]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/9.png
|
||||
[18]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/10.png
|
||||
[19]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/11.png
|
||||
[20]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/12.png
|
||||
[21]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/13.png
|
||||
[22]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/14.png
|
||||
[23]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/15.png
|
||||
[24]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/16.png
|
@ -0,0 +1,266 @@
|
||||
如何在 Ubuntu16.04 中用 Apache 部署 Jenkins 自动化服务器
|
||||
============================================================
|
||||
|
||||
|
||||
Jenkins 是从 Hudson 项目衍生出来的自动化服务器。Jenkins 是一个基于服务器的应用程序,运行在 Java servlet 容器中,它支持包括 Git、SVN 以及 Mercurial 在内的多种 SCM(Source Control Management,源码控制工具)。Jenkins 提供了上百种插件帮助你的项目实现自动化。Jenkins 由 Kohsuke Kawaguchi 开发,在 2011 年使用 MIT 协议发布了第一个发行版,它是个免费软件。
|
||||
|
||||
在这篇指南中,我会向你介绍如何在 Ubuntu 16.04 中安装最新版本的 Jenkins。我们会用自己的域名运行 Jenkins,在 apache web 服务器中安装和配置 Jenkins,而且支持反向代理。
|
||||
|
||||
### 前提
|
||||
|
||||
* Ubuntu 16.04 服务器 - 64 位
|
||||
* Root 权限
|
||||
|
||||
### 第一步 - 安装 Java OpenJDK 7
|
||||
|
||||
Jenkins 基于 Java,因此我们需要在服务器上安装 Java OpenJDK 7。在这里,我们会从一个 PPA 仓库安装 Java 7,首先我们需要添加这个仓库。
|
||||
|
||||
默认情况下,Ubuntu 16.04 没有安装用于管理 PPA 仓库的 python-software-properties 软件包,因此我们首先需要安装这个软件。使用 apt 命令安装 python-software-properties。
|
||||
|
||||
`apt-get install python-software-properties`
|
||||
|
||||
下一步,添加 Java PPA 仓库到服务器中。
|
||||
|
||||
`add-apt-repository ppa:openjdk-r/ppa`
|
||||
|
||||
输入回车键
|
||||
|
||||
用 apt 命令更新 Ubuntu 仓库并安装 Java OpenJDK。`
|
||||
|
||||
`apt-get update`
|
||||
`apt-get install openjdk-7-jdk`
|
||||
|
||||
输入下面的命令验证安装:
|
||||
|
||||
`java -version`
|
||||
|
||||
你会看到安装到服务器上的 Java 版本。
|
||||
|
||||
[
|
||||
![在 Ubuntu 16.04 上安装 Java OpenJDK 7](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/1.png)
|
||||
][9]
|
||||
|
||||
### 第二步 - 安装 Jenkins
|
||||
|
||||
Jenkins 给软件安装包提供了一个 Ubuntu 仓库,我们会从这个仓库中安装 Jenkins。
|
||||
|
||||
用下面的命令添加 Jenkins 密钥和仓库到系统中。
|
||||
|
||||
`wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -`
|
||||
`echo 'deb https://pkg.jenkins.io/debian-stable binary/' | tee -a /etc/apt/sources.list`
|
||||
|
||||
更新仓库并安装 Jenkins。
|
||||
|
||||
`apt-get update`
|
||||
`apt-get install jenkins`
|
||||
|
||||
安装完成后,用下面的命令启动 Jenkins。
|
||||
|
||||
`systemctl start jenkins`
|
||||
|
||||
通过检查 Jenkins 默认使用的端口(端口 8080)验证 Jenkins 正在运行。我会像下面这样用 netstat 命令检测:
|
||||
|
||||
`netstat -plntu`
|
||||
|
||||
Jenkins 已经安装好了并运行在 8080 端口。
|
||||
|
||||
[
|
||||
![已经将 Jenkins 安装到 8080 端口](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/2.png)
|
||||
][10]
|
||||
|
||||
### 第三步 - 为 Jenkins 安装和配置 Apache 作为反向代理
|
||||
|
||||
在这篇指南中,我们会在一个 apache web 服务器中运行 Jenkins,我们会为 Jenkins 配置 apache 作为反向代理。首先我会安装 apache 并启用一些需要的模块,然后我会为 Jenkins 用域名 my.jenkins.id 创建虚拟 host 文件。请在这里使用你自己的域名并在所有配置文件中出现的地方替换。
|
||||
|
||||
从 Ubuntu 仓库安装 apache2 web 服务器。
|
||||
|
||||
`apt-get install apache2`
|
||||
|
||||
安装完成后,启用 proxy 和 proxy_http 模块以便将 apache 配置为 Jenkins 的前端服务器/反向代理。
|
||||
|
||||
`a2enmod proxy`
|
||||
`a2enmod proxy_http`
|
||||
|
||||
下一步,在 sites-available 目录创建新的虚拟 host 文件。
|
||||
|
||||
`cd /etc/apache2/sites-available/`
|
||||
`vim jenkins.conf`
|
||||
|
||||
粘贴下面的虚拟 host 配置。
|
||||
|
||||
```
|
||||
<Virtualhost *:80>
|
||||
ServerName my.jenkins.id
|
||||
ProxyRequests Off
|
||||
ProxyPreserveHost On
|
||||
AllowEncodedSlashes NoDecode
|
||||
|
||||
<Proxy http://localhost:8080/*>
|
||||
Order deny,allow
|
||||
Allow from all
|
||||
</Proxy>
|
||||
|
||||
ProxyPass / http://localhost:8080/ nocanon
|
||||
ProxyPassReverse / http://localhost:8080/
|
||||
ProxyPassReverse / http://my.jenkins.id/
|
||||
</Virtualhost>
|
||||
```
|
||||
|
||||
保存文件。然后用 a2ensite 命令激活 Jenkins 虚拟 host。
|
||||
|
||||
`a2ensite jenkins`
|
||||
|
||||
重启 Apache 和 Jenkins。
|
||||
|
||||
`systemctl restart apache2`
|
||||
`systemctl restart jenkins`
|
||||
|
||||
检查 Jenkins 和 Apache 正在使用 80 和 8080 端口。
|
||||
|
||||
`netstat -plntu`
|
||||
|
||||
[
|
||||
![检查 Apache 和 Jenkins 是否在运行](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/3.png)
|
||||
][11]
|
||||
|
||||
### 第四步 - 配置 Jenkins
|
||||
|
||||
Jenkins 用域名 'my.jenkins.id' 运行。打开你的 web 浏览器然后输入 URL。你会看到要求你输入初始管理员密码的页面。Jenkins 已经生成了一个密码,因此我们只需要显示并把结果复制到密码框。
|
||||
|
||||
用 cat 命令显示 Jenkins 初始管理员密码。
|
||||
|
||||
`cat /var/lib/jenkins/secrets/initialAdminPassword`
|
||||
|
||||
a1789d1561bf413c938122c599cf65c9
|
||||
|
||||
[
|
||||
![获取 Jenkins 管理员密码](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/4.png)
|
||||
][12]
|
||||
|
||||
将结果粘贴到密码框然后点击 ‘**Continue**’。
|
||||
|
||||
[
|
||||
![安装和配置 Jenkins](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/5.png)
|
||||
][13]
|
||||
|
||||
现在为了后面能比较好的使用,我们需要在 Jenkins 中安装一些插件。选择 ‘**Install Suggested Plugin**’,点击它。
|
||||
|
||||
[
|
||||
![安装 Jenkins 插件](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/6.png)
|
||||
][14]
|
||||
|
||||
Jenkins 插件安装过程
|
||||
|
||||
[
|
||||
![Jenkins 安装完插件](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/7.png)
|
||||
][15]
|
||||
|
||||
安装完插件后,我们需要创建一个新的管理员密码。输入你的管理员用户名、密码、电子邮件等,然后点击 ‘**Save and Finish**’。
|
||||
|
||||
[
|
||||
![创建 Jenkins 管理员账户](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/8.png)
|
||||
][16]
|
||||
|
||||
点击 start 开始使用 Jenkins。你会被重定向到 Jenkins 管理员面板。
|
||||
|
||||
[
|
||||
![重定向到管理员面板](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/9.png)
|
||||
][17]
|
||||
|
||||
成功完成 Jenkins 安装和配置。
|
||||
|
||||
[
|
||||
![Jenkins 管理员面板](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/10.png)
|
||||
][18]
|
||||
|
||||
### 第五步 - Jenkins 安全
|
||||
|
||||
在 Jenkins 管理员面板,我们需要为 Jenkins 配置标准的安全,点击 ‘**Manage Jenkins**’ 和 ‘**Configure Global Security**’。
|
||||
|
||||
[
|
||||
![Jenkins 全局安全设置](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/11.png)
|
||||
][19]
|
||||
|
||||
Jenkins 在 ‘**Access Control**’ 部分提供了多种认证方法。为了能够控制所有的用户权限,我选择了 ‘**Matrix-based Security**’。在复选框 ‘**User/Group**’ 中启用 admin 用户。通过**勾选所有选项**给 admin 所有权限,给 anonymous 只读权限。现在点击 ‘**Save**’。
|
||||
|
||||
[
|
||||
![配置 Jenkins 权限](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/12.png)
|
||||
][20]
|
||||
|
||||
你会被重定向到面板,如果出现了登录选项,只需输入你的管理员账户和密码。
|
||||
|
||||
### 第六步 - 测试一个简单的自动化任务
|
||||
|
||||
在这一部分,我想为 Jenkins 服务测试一个简单的任务。为了测试 Jenkins 我会创建一个简单的任务,并用 top 命令查看服务器的负载。
|
||||
|
||||
在 Jenkins 管理员面板上,点击 ‘**Create New Job**’。
|
||||
|
||||
[
|
||||
![在 Jenkins 中创建新的任务](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/13.png)
|
||||
][21]
|
||||
|
||||
输入任务的名称,在这里我用 ‘Checking System’,选择 ‘**Freestyle Project**’ 然后点击 ‘**OK**’。
|
||||
|
||||
[
|
||||
![配置 Jenkins 任务](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/14.png)
|
||||
][22]
|
||||
|
||||
进入 ‘**Build**’ 标签页。在 ‘**Add build step**’,选择选项 ‘**Execute shell**’。
|
||||
|
||||
在输入框输入下面的命令。
|
||||
|
||||
`top -b -n 1 | head -n 5`
|
||||
|
||||
点击 ‘**Save**’。
|
||||
|
||||
[
|
||||
![启动 Jenkins 任务](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/15.png)
|
||||
][23]
|
||||
|
||||
现在你是在任务 ‘Project checking system’的任务页。点击 ‘**Build Now**’ 执行任务 ‘checking system’。
|
||||
|
||||
任务执行完成后,你会看到 ‘**Build History**’,点击第一个任务查看结果。
|
||||
|
||||
下面是 Jenkins 任务执行的结果。
|
||||
|
||||
[
|
||||
![构建和运行 Jenkins 任务](https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/16.png)
|
||||
][24]
|
||||
|
||||
到这里就介绍完了在 Ubuntu 16.04 中用 Apache web 服务器安装 Jenkins 的内容。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/
|
||||
|
||||
作者:[Muhammad Arul ][a]
|
||||
译者:[ictlyh](https://github.com/ictlyh)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 组织编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://twitter.com/howtoforgecom
|
||||
[1]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#prerequisite
|
||||
[2]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#step-install-java-openjdk-
|
||||
[3]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#step-install-jenkins
|
||||
[4]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#step-install-and-configure-apache-as-reverse-proxy-for-jenkins
|
||||
[5]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#step-configure-jenkins
|
||||
[6]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#step-jenkins-security
|
||||
[7]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#step-testing-a-simple-automation-job
|
||||
[8]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#reference
|
||||
[9]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/1.png
|
||||
[10]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/2.png
|
||||
[11]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/3.png
|
||||
[12]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/4.png
|
||||
[13]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/5.png
|
||||
[14]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/6.png
|
||||
[15]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/7.png
|
||||
[16]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/8.png
|
||||
[17]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/9.png
|
||||
[18]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/10.png
|
||||
[19]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/11.png
|
||||
[20]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/12.png
|
||||
[21]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/13.png
|
||||
[22]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/14.png
|
||||
[23]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/15.png
|
||||
[24]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/16.png
|
Loading…
Reference in New Issue
Block a user