linux安装jenkins 【详细教程】

步骤

前提

1、确保jdk已经安装,至少是java8以上,如果没有安装,可以参考https://blog.csdn.net/Think_and_work/article/details/122842622?spm=1001.2014.3001.5502

1、下载jenkins

方式一:公众号获取

关注"I am Walker",回复"jenkins"获取

方式二:官网下载

http://mirrors.jenkins-ci.org/redhat/
在这里可以选择自己想要的版本

image.png

2、下载好之后移动到linux虚拟机上

可以使用xftp进行转移


image.png

3、解压

rpm -ivh jenkins-2.174-1.1.noarch.rpm

[root@localhost jenkins]# rpm -ivh jenkins-2.174-1.1.noarch.rpm 
warning: jenkins-2.174-1.1.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID d50582e6: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:jenkins-2.174-1.1                ################################# [100%]

4、配置jenkins中的java路径

(1)查询java安装路径

[root@localhost develop]# whereis java
java: /opt/env/jdk1.8.0_202/bin/java

(2)修改/etc/init.d/jenkins文件 ,配置jdk安装路径

vim /etc/init.d/jenkins
下拉到candidates这个变量,然后将java的安装路径添加进去

image.png

5、启动

service jenkins start

若显示ok即可


image.png

6、测试访问

默认的端口是8080
访问http://ip:8080即可,ip是自己虚拟机的ip

第一次进入比较缓慢,等待进入,之后进入到这个页面,需要获取管理员的密码


image.png

7、获取密码

(1)复制该地址,然后读取该地址的内容即可,里面就是我们需要的密码


image.png

image.png

(2)点击继续,进入到插件安装界面,一般新手的推荐选择“安装推荐的插件”


image.png
image.png
image.png

就会装载这些插件了。

8、创建账户并保存

image.png

9、实例配置

image.png

image.png

本次的安装教程就到此为止了,后续的教程会继续发上。

问题

1、ERROR: cannot verify pkg.jenkins.io's certificate, issued by ‘/C=US/O=Let's Encrypt/CN=R3’:

Issued certificate has expired.

[root@localhost kit]# wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
--2022-02-11 09:17:59--  https://pkg.jenkins.io/redhat-stable/jenkins.repo
Resolving pkg.jenkins.io (pkg.jenkins.io)... 151.101.2.133, 151.101.66.133, 151.101.130.133, ...
Connecting to pkg.jenkins.io (pkg.jenkins.io)|151.101.2.133|:443... connected.
ERROR: cannot verify pkg.jenkins.io's certificate, issued by ‘/C=US/O=Let's Encrypt/CN=R3’:
  Issued certificate has expired.
To connect to pkg.jenkins.io insecurely, use `--no-check-certificate'.

解决方式:

sudo yum install -y ca-certificates

2、stat: cannot stat ‘/var/cache/jenkins’: No such file or directory

y

[root@localhost kit]# rpm -ivh jenkins-2.213-1.1.noarch.rpm 
warning: jenkins-2.213-1.1.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID d50582e6: NOKEY
Preparing...                          ################################# [100%]
stat: cannot stat ‘/var/cache/jenkins’: No such file or directory
stat: cannot stat ‘/var/log/jenkins’: No such file or directory
stat: cannot stat ‘/var/lib/jenkins’: No such file or directory
error: %pre(jenkins-2.213-1.1.noarch) scriptlet failed, exit status 1
error: jenkins-2.213-1.1.noarch: install failed

原因:
因为在之前已经安装过jenkins,新建了jenkins文件,将其删除即可


image.png

3、插件安装失败

image.png

可能是因为版本较低的原因,可以选择安装最新的版本

你可能感兴趣的:(linux安装jenkins 【详细教程】)