BlueXIII's Blog

热爱技术,持续学习

0%

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 user@xxx.xxx.xxx.xxx

Jenkins主机发布脚本

vi deploy-woegotv-admin-api.sh

1
2
3
4
5
6
7
8
9
10
11
echo 'stop process...'
ssh user@xxx.xxx.xxx.xxx '~/deploy/stopadmin.sh'
sleep 3
echo 'delete files...'
ssh user@xxx.xxx.xxx.xxx '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 user@xxx.xxx.xxx.xxx:~/deploy/
echo 'start process...'
ssh user@xxx.xxx.xxx.xxx '~/deploy/startadmin.sh'
echo 'done'

应用主机启停脚本

vi startadmin.sh

1
2
3
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

1
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