共计 922 个字符,预计需要花费 3 分钟才能阅读完成。
jenkins.sh:
#!/bin/bash
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.292.b10-1.el7_9.x86_64
pid=`ps -ef | grep jenkins.war | grep -v 'grep'| awk '{print $2}'| wc -l`
if ["$1" = "start"];then
if [$pid -gt 0];then
echo 'jenkins is running...'
else
nohup java -jar jenkins.war > jenkins.log --httpPort=8080 2>&1 &
fi
elif ["$1" = "stop"];then
exec ps -ef | grep jenkins | grep -v grep | awk '{print $2}'| xargs kill -9
echo 'jenkins is stop..'
else
echo "Please input like this:"./jenkins.sh start"or"./jenkins stop""
fi
开启 ./jenkins.sh start
进行 ./jenkins.sh stop
start.sh
#!/bin/bash
export BUILD_ID=dontKillMe
export ENV=test
export GOPROXY=https://goproxy.cn,direct
export GO111MODULE=on
export GOPATH=/opt/go
export GOROOT=/usr/lib/golang
pid=$(netstat -nlp | grep :8081 | awk '{print $7}' | awk -F"/" '{print $1}');
if [-n "$pid"];then
kill -9 $pid
fi
cd /opt/go/src/dearm
git pull
go build main.go
mv main /opt/dearm
nohup /opt/dearm >> /opt/log/dearm.log 2>&1 &
应用 nohup 运行我的项目,肯定要加环境变量 export BUILD_ID=dontKillMe
go 目录:/opt/go/src/ 我的项目
jenkins 增加 gitee 插件
正文完