【一步到位】Jenkins的安装、部署、启动(完整教程)

一、测试环境

  • Linux系统 Centos 7

二、安装步骤:

1、安装jdk

我安装的是jdk8,此处就不多说了,自己百度哈,很简单

2、安装jenkins

首先依次执行如下三个命令:
2.1、导入镜像:

[root@centos7 ~]# sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
--2019-12-24 17:59:44--  https://pkg.jenkins.io/redhat-stable/jenkins.repo
Resolving pkg.jenkins.io (pkg.jenkins.io)... 52.202.51.185
Connecting to pkg.jenkins.io (pkg.jenkins.io)|52.202.51.185|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 85
Saving to: ‘/etc/yum.repos.d/jenkins.repo’100%[=====================================================================================================================================================>] 85          --.-K/s   in 0s      2019-12-24 18:00:47 (17.4 MB/s) - ‘/etc/yum.repos.d/jenkins.repo’ saved [85/85]

2.2、导入公钥

[root@centos7 ~]# sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

2.3、安装jenkins:

[root@centos7 ~]# yum install jenkins
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package jenkins.noarch 0:2.204.1-1.1 will be installed
--> Finished Dependency ResolutionDependencies Resolved===============================================================================================================================================================================================Package                                      Arch                                        Version                                           Repository                                    Size
===============================================================================================================================================================================================
Installing:jenkins                                      noarch                                      2.204.1-1.1                                       jenkins                                       60 MTransaction Summary
===============================================================================================================================================================================================
Install  1 PackageTotal download size: 60 M
Installed size: 61 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
jenkins-2.204.1-1.1.noarch.rpm FAILED                                          
http://pkg.jenkins.io/redhat-stable/jenkins-2.204.1-1.1.noarch.rpm: [Errno 12] Timeout on http://pkg.jenkins.io/redhat-stable/jenkins-2.204.1-1.1.noarch.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
Trying other mirror.
jenkins-2.204.1-1.1.noarch.rpm FAILED                                          
http://pkg.jenkins.io/redhat-stable/jenkins-2.204.1-1.1.noarch.rpm: [Errno 12] Timeout on http://pkg.jenkins.io/redhat-stable/jenkins-2.204.1-1.1.noarch.rpm: (28, 'Connection timed out after 30001 milliseconds')
Trying other mirror.
jenkins-2.204.1-1.1.noarch.rpm                                                                                                                                          |  60 MB  00:04:26     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows:
authconfig-6.2.8-30.el7.x86_64 has missing requires of newt-pythonInstalling : jenkins-2.204.1-1.1.noarch                                                                                                                                                  1/1 Verifying  : jenkins-2.204.1-1.1.noarch                                                                                                                                                  1/1 Installed:jenkins.noarch 0:2.204.1-1.1                                                                                                                                                                 Complete!

2.4、修改配置文件

[root@centos7 ~]# vi /etc/sysconfig/jenkins

修改这部分:

## Default:     8080
## ServiceRestart: jenkins
#
# Port Jenkins is listening on.
# Set to -1 to disable
#
JENKINS_PORT="8091"## Type:        string
## Default:     ""
## ServiceRestart: jenkins

2.5、启动jenkins

[root@centos7 ~]# systemctl  start  jenkins
Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details.

2.6、查看jenkins的启动状态

[root@centos7 ~]# systemctl status  jenkins
● jenkins.service - LSB: Jenkins Automation ServerLoaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)Active: failed (Result: exit-code) since Tue 2019-12-24 18:12:05 CST; 11s agoDocs: man:systemd-sysv-generator(8)Process: 23175 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=1/FAILURE)Dec 24 18:12:05 centos7  systemd[1]: Starting LSB: Jenkins Automation Server...
Dec 24 18:12:05 centos7 runuser[23180]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
Dec 24 18:12:05 centos7 jenkins[23175]: Starting Jenkins bash: /usr/bin/java: Is a directory
Dec 24 18:12:05 centos7  systemd[1]: jenkins.service: control process exited, code=exited status=1
Dec 24 18:12:05 centos7 jenkins[23175]: [FAILED]
Dec 24 18:12:05 centos7 systemd[1]: Failed to start LSB: Jenkins Automation Server.
Dec 24 18:12:05 centos7  systemd[1]: Unit jenkins.service entered failed state.
Dec 24 18:12:05 centos7 systemd[1]: jenkins.service failed.

出现这种情况的解决办法是:

修改 jenkins 的配置文件中使用的 jdk 路径

[root@centos7 ~]#  echo $JAVA_HOME
/usr/java/jdk1.8.0_191[root@centos7 ~]# vi /etc/init.d/jenkins 

 

注意:这里echo $JAVA_HOME 出来的路径,后面一定跟启动路径(/bin/java)

2.7、重启并查看 jenkins 状态

systemctl daemon-reloadsystemctl restart jenkins 

我的 jenkins 启动后是这样子的:

[root@centos7 docker]# systemctl daemon-reload
[root@centos7 docker]# systemctl restart jenkins 
[root@centos7 docker]# systemctl status jenkins
● jenkins.service - LSB: Jenkins Automation ServerLoaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled)Active: active (running) since Tue 2019-12-24 18:16:08 CST; 12s agoDocs: man:systemd-sysv-generator(8)Process: 23787 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=0/SUCCESS)CGroup: /system.slice/jenkins.service└─23832 /software/jdk1.8.0_191/bin/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --logfile=/v...Dec 24 18:16:02 centos7 systemd[1]: Starting LSB: Jenkins Automation Server...
Dec 24 18:16:02 centos7 runuser[23792]: pam_unix(runuser:session): session opened for user jenkins by (uid=0)
Dec 24 18:16:08 centos7 runuser[23792]: pam_unix(runuser:session): session closed for user jenkins
Dec 24 18:16:08 centos7 systemd[1]: Started LSB: Jenkins Automation Server.
Dec 24 18:16:08 centos7 jenkins[23787]: Starting Jenkins [  OK  ]
[root@centos7 ~]# lsof -i:8091
COMMAND   PID    USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
java    23832 jenkins  160u  IPv4 11605726      0t0  TCP *:jamlink (LISTEN)

好了,此时已经表示 Jenkins 顺利安装并启动成功了!
 

2.8、访问浏览器: http://localhost:8091/ 出现如下提示:

Please wait while Jenkins is getting ready to work...

解决办法
进入jenkins的工作目录(/var/lib/jenkins/),打开 hudson.model.UpdateCenter.xml
把 http://updates.jenkins-ci.org/update-center.json 改成如下三个地址之一均可:

# 修改更新地址(到其中一种即可):
http://mirror.xmission.com/jenkins/updates/update-center.jsonhttp://updates.jenkins.io/update-center.jsonhttps://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.jsonhttp://mirror.esuni.jp/jenkins/updates/update-center.json

然后重启并查看 jenkins 状态:

[root@centos7 ~]# vi hudson.model.UpdateCenter.xml 
[root@centos7 ~]# systemctl daemon-reload
[root@centos7 ~]# systemctl restart jenkins 
[root@centos7 ~]# systemctl status jenkins

查看密码:

cat /var/lib/jenkins/secrets/initialAdminPassword

然后直接选推荐安装的插件,或者直接下一步就完事儿了!
 

2.9、设置jenkin语言为中文

需要的话,还可以设置语言为中文

  • 1、系统管理->插件管理->可用插件:安装Locale Plugin插件(https://wiki.jenkins.io/display/JENKINS/Locale+Plugin),重启;
  • 2、如果没有搜索到这个插件,就直接官网(https://github.com/jenkinsci/locale-plugin或者https://updates.jenkins.io/download/plugins/locale/)下载安装:
  • 系统管理->插件管理->高级->上传插件,安装重启;
  • 3、系统管理->系统管理->locale language->输入zh_CN

 

  • 最新版本的jenkins,即使设置了zh_CN也有可能是中英文混搭风, 因为最新版本没有针对所有内容都翻译成中文。

三、卸载

[root@centos7 ~]# rpm -e jenkins
warning: /etc/sysconfig/jenkins saved as /etc/sysconfig/jenkins.rpmsave
warning: /etc/init.d/jenkins saved as /etc/init.d/jenkins.rpmsave
[root@centos7 ~]# systemctl stop jenkins
Failed to stop jenkins.service: Access denied
See system logs and 'systemctl status jenkins.service' for details.
Failed to get load state of jenkins.service: Access denied
[root@centos7 ~]# rpm -ql jenkins
package jenkins is not installed
[root@centos7 ~]# find / -iname jenkins | xargs -n 1000 rm -rf
[root@centos7 ~]#

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/19268.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

vue筛选框封装

点击对默认查询条件之外的条件进行 增加或删除 在使用的组件或标签加入:filtrateList"filtrateList"传入条件查询数组 当前demo写在xk-page中,就以xk-page组件为例 <xk-upage :filtrateList"filtrateList" :queryArr"queryArr"></xk-…

【Zookeeper】终端操作常用命令

文章目录 服务端常用命令客户端常用命令 zookeeper版本3.7.1 Zookeeper是一个开源的分布式协调服务。 Zookeeper是Apache软件基金会的一个项目&#xff0c;它提供了分布式应用程序协调的通用服务&#xff0c;如分布式同步、命名服务、集群维护等&#xff0c;以简化分布式应用协…

vue打包、网站运行速度优化

最近在做公司的官网&#xff0c;遇到的首要问题就是初次进入网站时&#xff0c;加载很慢&#xff0c;首页的视频和字体甚至需要30秒才能完全展示出来&#xff0c;用户体验可以说时很差了。接下来说几个优化的点。 一、减小图片的体积 如果项目中的图片过于多&#xff0c;并且体…

HTML5基础语法与标签

一、 HTML5介绍 HTML5是什么&#xff1f; HTML5是超文本标记语言&#xff08;HTML&#xff09;的第五个主要版本&#xff0c;用于描述网页结构和呈现内容。它是到目前为止最新且最强大的HTML版本。 HTML5语法约定 1.标签是HTML语法中的基本单位&#xff0c;由尖括号 ​<>…

【CSS加载动画特效】28种纯CSS实现的加载loading动态特效(附源码)

文章目录 写在前面涉及知识点效果展示1、Loading节点的创建2、部分效果的实现源码1&#xff09;三点加载动画Html代码CSS样式代码 2&#xff09;圆点矩阵加载特效Html代码CSS样式代码 3&#xff09;圆形轨迹加载动画Html代码Css样式代码 4&#xff09;栅栏式加载动画Html代码Cs…

Linux--查看常驻进程:ps

进程分为瞬时进程和常驻进程 瞬时进程&#xff1a;瞬间完成从加载到内存、显示在输出设备、退出过程 int main() {printf("hello world!\n");return 0; } 常驻进程&#xff1a;一直在内存中 int main() {while (1){printf("hello world!\n");sleep(1);…

itheima苍穹外卖项目学习笔记--Day1:项目介绍与开发环境搭建

苍穹外卖 Day1:a. 项目概述b. 开发环境搭建(1). 前端环境搭建(2). 后端环境搭建(3). 前后端联调 c. 完善登录功能d. Swagger Day1: a. 项目概述 b. 开发环境搭建 (1). 前端环境搭建 前端工程基于 nginx 运行启动nginx&#xff1a;双击 nginx.exe 即可启动 nginx 服务&#x…

亚马逊云科技推出的一项完全托管的生成式AI服务——Amazon Bedrock

在全球生成式AI浪潮兴起之际&#xff0c;以“智联世界&#xff0c;生成未来”为主题的2023世界人工智能大会&#xff08;WAIC 2023&#xff09;于7月6日在上海世博中心拉开帷幕。大会首日&#xff0c;亚马逊云科技携生成式AI产品Amazon Bedrock亮相大会现场&#xff0c;亚马逊云…

蓝桥杯每日一练专栏导读2

之前一直更新的是C、C相关的题目&#xff0c;但作为一名前端工程师&#xff0c;还是对Js了解的更多一些&#xff0c;所以从此以后停止更新C/C相关内容&#xff0c;改为更新Js相关的练习题。 内容 更新的内容依旧是蓝桥杯大赛官网提供的习题。每一道题都会提供详细的解题思路&a…

前端VUE

基础语法 安装VUE 入门Demo 定义的Vue只有id是app的才能使用他的变量值name&#xff0c;age&#xff0c;gender。 - 方法非id是app的也不可以调用。 <!DOCTYPE html> <html><head><meta charset"utf-8"><title></title><!…

0305kali linux配置运行-docker-macos aarm64

文章目录 1 下载运行2 配置2.1 配置系统环境2.2 配置SSH服务2.3 安装工具 3 问题总结结语 1 下载运行 拉取kali linux镜像 docker pull kalilinux/kali-rolling该镜像为“纯净版”系统&#xff0c;没有任何工具&#xff0c;体积小。下面当我们运行起来之后&#xff0c;到容器中…

华为云CodeArts DevSecOps系列插件——助力更高效的软件研发

HDC期间入驻华为云&#xff0c;可参与Toolkit插件抽奖活动&#xff0c;活动链接在文末 一、前言 DevOps的概念想必大家都不陌生&#xff0c;它是一组过程、方法与系统的统称&#xff0c;通过它可以对交付速率、协作效率、部署频率速率、质量、安全和可靠性等进行提升改善。相比…