yum安装jenkins

avatar 2023年3月26日18:10:34 评论 262 次浏览

最近在整合环境,前面基础环境都整合好了,就差jenkins了,原本想着使用docker安装的,但是最近使用docker安装插件的时候国内的443端口有问题,导致插件一直安装失败,早知道就自己做一个定制的docker镜像了,也不需要安装插件直接使用了。废话不说,看一下使用yum安装jenkins的方法。

 [root@wulaoer.org ~]# wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat/jenkins.repo
 [root@wulaoer.org ~]# rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
 [root@wulaoer.org ~]# yum install jenkins-2.346

这里注意,在yumjenkins的时候源也是一样有问题,换成国内的即可,可以参考下面扩展部分。

jenkins安装后简单配置一下,用户和路径,然后启动起来

 [root@wulaoer.org ~]# vim /etc/sysconfig/jenkins
 ............................................
 #
 JENKINS_HOME="/ops/jenkins"
 
 ## Type:        string
 ## Default:     ""
 ## ServiceRestart: jenkins
 #
 # Java executable to run Jenkins
 # When left empty, we'll try to find the suitable Java.
 #
 JENKINS_JAVA_CMD=""
 
 ## Type:        string
 ## Default:     "jenkins"
 ## ServiceRestart: jenkins
 #
 # Unix user account that runs the Jenkins daemon
 # Be careful when you change this, as you need to update
 # permissions of $JENKINS_HOME and /var/log/jenkins,
 # and if you have already run Jenkins, potentially other
 # directories such as /var/cache/jenkins .
 #
 JENKINS_USER="root"
 .........................................................

jenkins配置好后,我们需要在配置一下jdk,这里就不多说了,可以参考:https://www.wulaoer.org/?p=487

 [root@wulaoer.org ~]# vim /etc/init.d/jenkins
 ................................
 /etc/alternatives/java
 /usr/lib/jvm/java-1.8.0/bin/java
 /usr/lib/jvm/jre-1.8.0/bin/java
 /usr/lib/jvm/java-11.0/bin/java
 /usr/lib/jvm/jre-11.0/bin/java
 /usr/lib/jvm/java-11-openjdk-amd64
 /usr/bin/java
 /usr/local/jdk/bin/java #增加jdk的路径
 .............................

然后启动jenkins,并设置成开机自启动。

 [root@wulaoer.org ~]# systemctl enable jenkins
 [root@wulaoer.org ~]# systemctl start jenkins

后面就都正常了,如果安装插件的时候超时或者失败,可以把jenkins的目录下的hudson.model.UpdateCenter.xml中的连接改成国内的即可。

扩展部分

yum总是超时,拉取不了,修改国内的源即可

 Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
 jenkins-2.346-1.1.noarch.rpm   FAILED
 http://pkg.jenkins.io/redhat/jenkins-2.346-1.1.noarch.rpm: [Errno 12] Timeout on https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat/jenkins-2.346-1.1.noarch.rpm: (28, 'Operation timed out after 30741 milliseconds with 0 out of 0 bytes received')

解决方法

把指向国外的源换成国内的,但是国内的https太慢了,直接换成http即可

 [root@wulaoer.org ~]# cd /etc/yum.repos.d/
 [root@wulaoer.org yum.repos.d]# vim jenkins.repo
 [jenkins]
 name=Jenkins
 #baseurl=http://pkg.jenkins.io/redhat
 baseurl=http://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat
 gpgcheck=1
avatar
  • 未经博主允许,禁止转载本博客任何内容,如需转载请留言,谢谢合作!!!
  • 转载注明:yum安装jenkins | 吴老二

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: