1.下载配置文件
wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
2.导入公钥
rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
3.安装
yum -y install jenkins
然后后面跟着安装就行了,这里要注意一点,Jenkins的环境变量只在/usr/bin下和/usr/sbin下获取,所以,,在系统中配置的是获取不到的,比如M2_HOME和JAVA_HOME,加个软连接过去就行了:
ln -s /usr/local/java/jdk1.8.0_171/bin/java /usr/bin/java
配置好的sh脚本:
echo "当前目录:/var/lib/jenkins/workspace/"
whoami
echo "开始构建..."
mvn clean install -Dmaven.test.skip=true
echo "杀死进程..."
pkill -f eureka-server-1.0.0.jar
echo "清空原应用"
rm -rf /data/application/eureka-server-1.0.0.jar
rm -rf /data/application/eureka-server.log
echo "移动新文件..."
cp /var/lib/jenkins/workspace/eureka-sit/eureka-server/target/eureka-server-1.0.0.jar /data/application
echo "启动程序..."
source /etc/profile
BUILD_ID=DONTKILLME
nohup java -jar /data/application/eureka-server-1.0.0.jar --spring.cloud.config.profile=sit >eureka-server.log & 2>&1 &
echo "查看是否已启动..."
ps -ef|grep eureka-serve
echo "完成构建"