加载中...

jenkins部署

参考:https://blog.csdn.net/lazycheerup/article/details/83928548

中文网:http://www.jenkins.org.cn/

Jenkins官方网址: http://Jenkins-ci.org/

安装方式一:

wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo

如果出现以下报错,安装一下证书yum install -y ca-certificates

错误: 无法验证 pkg.jenkins.io 的由 “/C=US/O=Let's Encrypt/CN=R3” 颁发的证书:
颁发的证书已经过期。
要以不安全的方式连接至 pkg.jenkins.io,使用“--no-check-certificate”。

或者在结尾添加--no-check-certificate

wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo --no-check-certificate
cat /etc/yum.repos.d/jenkins.repo
[jenkins]
name=Jenkins-stable
baseurl=http://pkg.jenkins.io/redhat-stable
gpgcheck=1

rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

安装方式二:

想安装指定版本的可以直接使用国内清华大学的镜像站

https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat-stable/

例如安装2.346.3-1.1版本

wget https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat-stable/jenkins-2.346.3-1.1.noarch.rpm
yum -y localinstall jenkins-2.346.3-1.1.noarch.rpm
或者rpm-ivh jenkins-2.346.3-1.1.noarch.rpm

安装完成之后几个重要的配置:

#WAR包  /usr/share/java/jenkins.war  
#默认的JENKINS_HOME目录 /var/lib/jenkins/    
#启动脚本配置文件:/usr/lib/systemd/system/jenkins.service 

启动:

systemctl start jenkins

出现如下报错:Failed to start Jenkins Continuous Integration Server,是因为官方安装的jenkins在2.361.1及以上需要jdk11,具体对应版本可查看:https://pkg.jenkins.io/redhat-stable/

新增一个jdk11,在/usr/lib/systemd/system/jenkins.service 中指定下jdk11版本所在位置即可

#Environment="JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64"
Environment="JAVA_HOME=/usr/local/jdk-11.0.21"

重新加载systemd并启动jenkins,启动时间会有点长

systemctl daemon-reload
systemctl start jenkins

查看状态,在/var/lib/jenkins/secrets/initialAdminPassword会得到一个token

[root@nacos jdk-11.0.21]# systemctl status jenkins
● jenkins.service - Jenkins Continuous Integration Server
   Loaded: loaded (/usr/lib/systemd/system/jenkins.service; disabled; vendor preset: disabled)
   Active: activating (start) since 一 2024-01-29 16:10:52 CST; 1min 4s ago
 Main PID: 4821 (java)
   CGroup: /system.slice/jenkins.service
           └─4821 /usr/local/jdk-11.0.21/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=%C/jenkins/war --httpPort=8080

1月 29 16:11:10 nacos.hcece.lan jenkins[4821]: *************************************************************
1月 29 16:11:10 nacos.hcece.lan jenkins[4821]: *************************************************************
1月 29 16:11:10 nacos.hcece.lan jenkins[4821]: *************************************************************
1月 29 16:11:10 nacos.hcece.lan jenkins[4821]: Jenkins initial setup is required. An admin user has been created and a password generated.
1月 29 16:11:10 nacos.hcece.lan jenkins[4821]: Please use the following password to proceed to installation:
1月 29 16:11:10 nacos.hcece.lan jenkins[4821]: bcd1e162f8324f2b8f1021334bb1cccf
1月 29 16:11:10 nacos.hcece.lan jenkins[4821]: This may also be found at: /var/lib/jenkins/secrets/initialAdminPassword
1月 29 16:11:10 nacos.hcece.lan jenkins[4821]: *************************************************************
1月 29 16:11:10 nacos.hcece.lan jenkins[4821]: *************************************************************
1月 29 16:11:10 nacos.hcece.lan jenkins[4821]: *************************************************************
[root@nacos jdk-11.0.21]#
[root@nacos jdk-11.0.21]# cat /var/lib/jenkins/secrets/initialAdminPassword
bcd1e162f8324f2b8f1021334bb1cccf

打开控制台,默认端口时候8080,可以在/usr/lib/systemd/system/jenkins.service 中修改

默认地址:http://localhost:8080/

jack/123

插件导入:https://blog.csdn.net/zzy1078689276/article/details/77478418

默认插件目录是/var/lib/jenkins/plugins

posted @ 2024-02-21 15:44  沾沾自喜的混子  阅读(107)  评论(0编辑  收藏  举报