>. bashrc closes CentOS7's own firewall service systemctldisablefirewalld&&systemctlstopfirewa"/> >. bashrc closes CentOS7's own firewall service systemctldisablefirewalld&&systemctlstopfirewa">
Home >Computer Tutorials >Computer Knowledge >CentOS7 deploys cicd service in Jenkins
https://www.jenkins.io/zh/
hostnamectl set-hostname jenkins
echo "PS1='[e[37;1m][[e[36;40m][e[32;40m]u[e[33;40m]@[e[31;40m]h [e[34;40m]w[e[37;1m]]\$[e[m]'" >>.bashrc
systemctl disable firewalld && systemctl stop firewalld
sed -i 's/enforcing/disabled/' /etc/selinux/config && setenforce 0
yum install git -y
yum install -y java-1.8.0 yum install -y java-1.8.0-openjdk*
最新版: wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins.io/redhat/jenkins.repo 稳定版本: wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
最新版: rpm --import http://pkg.jenkins.io/redhat/jenkins.io.key 稳定版本 rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
ps:如果在以前从Jenkins导入过密钥,那么“rpm –import”将失败,因为在服务器上已经有了一个密钥。所以,这个错误信息可以忽略
### 安装当时最新稳定版 yum install -y jenkins ### rpm包安装指定版本,具体当前稳定版是哪个?https://www.jenkins.io/zh/download/ # redhat老版本 https://mirror.tuna.tsinghua.edu.cn/jenkins/redhat/ # redhat稳定版 https://mirror.tuna.tsinghua.edu.cn/jenkins/redhat-stable/ # 下载稳定版 wget https://mirror.tuna.tsinghua.edu.cn/jenkins/redhat-stable/jenkins-2.303.2-1.1.noarch.rpm # 需要的依赖软件 yum install daemonize -y # 开始安装 [root@jenkins ~]#rpm -ivh jenkins-2.303.2-1.1.noarch.rpm Preparing...################################# [100%] Updating / installing... 1:jenkins-2.303.2-1.1################################# [100%]
格式化磁盘 mkfs.ext4 /dev/vdb 创建data目录 mkdir /data/ 挂载目录 mount /dev/vdb /data 设置开机自动挂载 echo "/dev/vdb /data ext4 defaults 0 0" >> /etc/fstab 创建Jenkins目录 mkdir /data/jenkins 设置Jenkins目录所属组所属用户 chown -R jenkins.jenkins /data/jenkins/
ps:此处是因为Jenkins的端口号默认是8080,与tomcat的默认端口冲突 所以可以根据自己的条件判断是否需要修改,此处我是已经修改为9999端口 ps:此处是因为Jenkins的用户默认是jenkins,我们可以改为root用户来管理jenkins vim /etc/sysconfig/jenkins # 配置Jenkins的运行用户,这里不是登录用户 JENKINS_USER="root" # 配置Jenkins的端口 JENKINS_PORT="8080" # 配置Jenkins的目录 JENKINS_HOME="/data/jenkins" # 配置资源限制 JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Xms256m -Xmx512m -XX:MaxNewSize=256m"
systemctl start jenkins && /sbin/chkconfig jenkins on && systemctl status jenkins
cat /var/lib/jenkins/secrets/initialAdminPassword
打开xxx.xxx.xxx.xxx:8080
选择默认推荐即可,会安装通用的社区插件,剩下的可以在使用的时候再进行安装。
The above is the detailed content of CentOS7 deploys cicd service in Jenkins. For more information, please follow other related articles on the PHP Chinese website!