jenkins安装教程
安装流程参考
https://blog.csdn.net/weixin_43487532/article/details/122556323
不行就再来一遍,重装解决90%问题
接下来开启防火墙8080端口,开放云服务器安全组8080端口
浏览器访问,按照流程走下去,然后进入控制台,点击系统管理,安装插件,Maven Integration plugin,git。
创建项目,注意名称最好和你的项目名称一样,然后配置git,脚本
贴一下我的脚本
#!/bin/bash
source ~/.bash_profile
source /etc/profile
echo "==========definition param=========="
APP_NAME=yssz-courseware-learning
APP_JAR=$APP_NAME.jar
#进入jenkins项目
echo "==========join jenkins $APP_NAME workspace=========="
sudo cd /var/lib/jenkins/workspace/$APP_NAME/
#创建临时存放项目的位置
echo "==========create $APP_NAME project workspace=========="
sudo mkdir /software/project/$APP_NAME
#将项目从jenkins复制到临时位置
echo "==========copy $APP_NAME project to projectWork=========="
sudo \cp -R ../$APP_NAME/* /software/project/$APP_NAME
#进入项目
echo "==========go $APP_NAME projectWork=========="
cd /software/project/$APP_NAME
#打包
echo "==========maven clean package=========="
mvn clean
mvn package
#创建存放jar的文件夹
echo "==========create jarRun $APP_NAME workspace=========="
sudo mkdir -vp /software/jars/$APP_NAME/
#把jar存到专门的文件夹
echo "==========copy jar file to jarRun work=========="
cp /software/project/$APP_NAME/target/yssz-courseware-learning-0.0.1-SNAPSHOT.jar /software/jars/$APP_NAME/
#
echo "==========delete target file=========="
rm -rf target*
echo "==========go jar workspace =========="
cd /software/jars/$APP_NAME/
echo "==========update jar project name=========="
#这里的jar包名需要改
mv -f yssz-courseware-learning-0.0.1-SNAPSHOT.jar $APP_NAME.jar
echo "==========chmod file auth =========="
chmod 777 $APP_NAME.jar
echo "==========kill already exists jar start =========="
tpid=`ps -ef | grep yssz | grep -v grep | awk '{print $2}' | awk 'NR == 1'`
if [ ${tpid} ]; then
echo "**********************Stop jar**********************"
kill -9 $tpid
fi
echo "==========kill jar end =========="
#ps -ef | grep "$APP_NAME" | grep -v grep |awk "{print $2}" |xargs kill -9
echo "==========run java project=========="
nohup java -jar /software/jars/$APP_NAME/$APP_NAME.jar &
echo "********************************************************************"
echo "****如果脚本使用nohup启动,则必须在他之前指定BUILD_ID(名字可以随便定义)**"
echo "********************************************************************"
BUILD_ID=course-ware
nohup java -jar $APP_NAME.jar > ../$APP_NAME/nohup.out 2>&1 &
echo "==========SUCCESS=========="
脚本一定要写好,会出很多错误。
准备就绪后点构建,然后迎接无尽的报错吧!