Jenkins服务搭建

新建用户

useradd -d/home/jenkins jenkins
passwd jenkins

内网环境中安装polipo将socks5代理转HTTP

安装:
https://www.irif.fr/~jch/software/polipo/
rpm -i polipo-1.1.1-1.el6.x86_64.rpm
配置:
vi /etc/polipo/config
socksParentProxy = "IP:PORT"
socksProxyType = socks5
proxyPort = LOCALPORT
启动:
service polipo start

开防火墙

lokkit -p 9090:tcp

启动

java -jar jenkins.war --httpPort=9090

WEB控制台

http://134.32.51.31:9090

自动发布

SSH认证

ssh-keygen -t rsa
ssh-copy-id -i [email protected]

Jenkins主机发布脚本

vi deploy-woegotv-admin-api.sh

echo 'stop process...'
ssh [email protected] '~/deploy/stopadmin.sh'
sleep 3
echo 'delete files...'
ssh [email protected] 'rm -f ~/deploy/woegotv-admin-api-1.0-SNAPSHOT.jar'
sleep 3
echo 'copy files...'
scp /home/jenkins/.jenkins/workspace/woegotv/admin-api/build/libs/woegotv-admin-api-1.0-SNAPSHOT.jar [email protected]:~/deploy/
echo 'start process...'
ssh [email protected] '~/deploy/startadmin.sh'
echo 'done'

应用主机启停脚本

vi startadmin.sh

export JAVA_HOME=/usr/jdk1.8.0_74
export PATH=$JAVA_HOME/bin:$PATH:$HOME/bin
nohup java -jar ~/deploy/woegotv-admin-api-1.0-SNAPSHOT.jar --spring.profiles.active=tst,druid,security >~/deploy/logs/woegotv.out 2>&1 &

vi stopadmin.sh

ps -fu`id -u`|grep woegotv-admin-api-1.0-SNAPSHOT.jar|grep -v grep|awk '{print $2}'|xargs kill -9

配置GitLab的WebHook

URL填写为Jenkins中GitLab插件生成的的http://xxx.xxx.xxx.xxx:9090/project/projectname

你可能感兴趣的:(Jenkins服务搭建)