您的位置:首页 > 编程语言

安装Jenkins+git获取代码+maven编译+远程发布

2018-03-29 15:05 711 查看
https://blog.csdn.net/bianchengninhao/article/details/79712916

安装git

yum install -y git

安装maven与ant

wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
yum -y install apache-maven
yum -y install ant

在centos7上安装Jenkins

安装

添加yum repos,然后安装
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key sudo yum install jenkins


启动和停止

sudo service jenkins start/stop/restart
sudo chkconfig jenkins on


修改jenkins启动用户

vi /etc/sysconfig/jenkins
JENKINS_USER=”jenkins”改成JENKINS_USER=”root”
这样就是以root用户启动了

修改jenkins端口

vi /etc/sysconfig/jenkins
JENKINS_PORT=”8080”
最后保存,重启jenkins服务
service jenkins restart
http://ip:8080可以继续了





安装maven插件
系统设置–管理插件



publish over ssh





系统管理–系统设置
添加 SSH Servers





点击保存
新建任务–





配置git地址



构建触发条件—-*/3 * * * * 每更新代码3秒后更新



build选项中使用一下命令不执行单元测试用例(clean install -Dmaven.test.skip=true)



设置构建前删除项目的target目录(rm -rf /var/lib/jenkins/workspace/business/target/)



设置工具成功后操作—(
mv /var/lib/jenkins/workspace/business/target/business-*.jar /var/lib/jenkins/workspace/business/target/business.jar;
yes|cp /var/lib/jenkins/workspace/business/target/business.jar /opt/tomcat/webapps/business.jar;
cd /opt/pj/;
echo “wsExecute shell Finish”
BUILD_ID=dontKillMe nohup ./restart.sh &
)无输出执行jar



设置构建成功后ssh远程代码操作—(
mv /opt/sshcache/business.jar /opt/pj/business.jar;
cd /opt/pj/;
./restart.sh > nohup.out &
)拷贝代码-执行重启jar脚本不要输出



关于jenkins publish over ssh远程发布使用参考

https://blog.csdn.net/houyefeng/article/details/51027885
https://blog.csdn.net/houyefeng/article/details/51027885
</div>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  服务器