0.环境说明:
①操作系统:centos7.4
②ROOT 权限
1.安装Jenkins依赖:
更新
yum install -y ca-certificates #更新证书,否则无法进行下一步 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-2023.key sudo yum upgrade # Add required dependencies for the jenkins package sudo yum install java-17-openjdk #此处安装失败后则需要单独安装jdk 17 sudo yum install jenkins sudo systemctl daemon-reload
安装openjdk-17
wget https://download.oracle.com/java/17/archive/jdk-17.0.8_linux-x64_bin.tar.gz tar -xvf jdk*.gz mv jdk-17.0.8 /usr/java ln -s /usr/java/bin/java /usr/bin/java sudo yum reinstall jenkins
配置环境变量,在/etc/profile最后加入
export JAVA_HOME=/usr/java export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
使环境变量生效:
source /etc/profile java -version #查看当前JDK版本
2.启动Jenkins:
#开机启动
1 sudo systemctl enable jenkins#启动jenkins
1 sudo systemctl start jenkins#查看jenkins状态
1 sudo systemctl status jenkins
初始化jenkins
cat /var/lib/jenkins/secrets/initialAdminPassword #访问时输入
访问方式
localhost:8080
更多:
防火墙配置参考:
jenkins 其它配置:
修改操作用户为root 修改 /etc/sysconfig/jenkins
JENKINS_USER="jenkins" #jenkins修改为root
赋予目录权限
chown -R root /var/log/jenkins chgrp -R root /var/log/jenkins chown -R root /var/lib/jenkins chgrp -R root /var/lib/jenkins chown -R root /var/cache/jenkins chgrp -R root /var/cache/jenkins
3.Jenkinsj节点配置问题:
在建立除master节点以外的其它节点,首先要保证两端的JAVA版本一致
遇到问题:“lib/jenkins/.ssh/known_hosts [SSH] No Known Hosts file was found at /var/lib/jenkins/.ssh/known_hosts.”
在节点管理页面修改认证机制:
近期评论