CentOS 7 安装 Jenkins

Others 2019-05-08 08:53:14 2019-05-08 08:53:14 2179 次浏览

https://www.cnblogs.com/stulzq/p/9291237.html

ubuntu https://juejin.im/post/5b6329c2e51d4519044ab85f


准备工作

首选需要安装JAVA环境 https://www.cnblogs.com/stulzq/p/9286878.html

如果你的系统没有自带git,那么也需要安装一个

yum install git

	<p>
		<code class="hljs" style="margin:auto;vertical-align:middle;display:block;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-attachment:initial;background-origin:initial;background-clip:initial;height:auto;overflow-x:auto;padding:5px !important;line-height:1.5 !important;font-family:&quot;font-size:12px !important;border:1px solid #CCCCCC !important;border-radius:3px !important;">安装java:</code>
		<p>
			<code class="hljs" style="margin:auto;vertical-align:middle;display:block;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-attachment:initial;background-origin:initial;background-clip:initial;height:auto;overflow-x:auto;padding:5px !important;line-height:1.5 !important;font-family:&quot;font-size:12px !important;border:1px solid #CCCCCC !important;border-radius:3px !important;">
yum install -y java

1.安装

第一种方法

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

yum install jenkins

第二种方法

直接下载 rpm 安装

各个版本地址 https://pkg.jenkins.io/

wget https://pkg.jenkins.io/redhat/jenkins-2.156-1.1.noarch.rpm
rpm -ivh jenkins-2.156-1.1.noarch.rpm

2.配置

vim /etc/sysconfig/jenkins  #监听端口 JENKINS_PORT="8080"

3.配置权限

为了不因为权限出现各种问题,这里直接使用root

修改用户为root

vim /etc/sysconfig/jenkins  #修改配置 $JENKINS_USER="root"

修改目录权限

chown -R root:root /var/lib/jenkins
chown -R root:root /var/cache/jenkins
chown -R root:root /var/log/jenkins

重启

service jenkins restart
ps -ef | grep jenkins

4.启动

systemctl start jenkins

5.安装

访问jenkins地址 http::8080


执行命令查看密码:

cat /var/lib/jenkins/secrets/initialAdminPassword



参考资料

https://www.jianshu.com/p/4c4f92209dd1