Java
下载jdk
1
| https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
|
环境变量(注意版本号)
1 2 3 4 5 6 7
| vi /etc/profile
export JAVA_HOME=/usr/local/java/jdk1.8.0_221 export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin
生效命令:source /etc/profile
|
测试
yum 安装 java
1
| yum install java-1.8.0-openjdk* -y
|
Jenkins
安装jenkins仓库
1 2
| 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
|
安装jenkins
启动和停止
1 2
| systemctl start jenkins systemctl stop jenkins
|
问题
如启动找不到java,可修改文件vi /etc/init.d/jenkins 大约82行,添加java路劲即可
修改目录
1 2 3 4
| vi /etc/sysconfig/jenkins
10行 JENKINS_HOME="/data/jenkins"
|
修改启动用户
1 2 3 4
| vi /etc/sysconfig/jenkins
29行 JENKINS_USER="root"
|
修改端口号
jenkins默认的端口号是8080,如果和服务器上8080端口占用了,可以修改默认的端口号
1 2 3 4
| vi /etc/sysconfig/jenkins
56行 JENKINS_PORT="8080"
|
访问jenkins
1 2 3 4
| ip:8080
初次登录,密码输入以下命令查看 cat /var/lib/jenkins/secrets/initialAdminPassword
|
jenkins 配置
全局配置
Manage Jenkins –> Global Tool Configuration –> JDK –> Maven
新建项目
新建Item –> hwzs –> General –> This project is parameterized –> 图1 –> 源码管理 –> 图2
–> 构建 –> 执行shell –> 图3