jenkins+maven+git Myth丶恋晨 2021-09-20 04:06 307阅读 0赞 本文只是搭建一个简单的打包环境。从而减轻工作负担,如果要深入对jenkins学习,请查看官方文档。 目的:使用jenkins+maven+git组合,对项目托管的源码,进行编译打包,而后部署到服务器上。 环境:tomcat8.5 jdk1.8 Maven 3.5 git 首先,在服务器上安装JDK,MAVEN,GIT.分别对路径进行配置 **git安装:** \[root@node1\]\# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker \[root@node1\]\# yum remove git \[root@node1\]\# tar xf git-2.7.6.tar.xz \[root@node1\]\# cd git-2.7.6 \[root@node1\]\# ./configure prefix=/usr/local/git/ \[root@node1\]\# make && make install \[root@node1\]\# echo “export PATH=$PATH:/usr/local/git/bin”>/etc/profile.d/git.sh **注**:git c lone 命令下载的代码会保存到现在所在的目录。 **JDK安装:** \[root@node1\]\# rpm -ivh jdk-8u144-linux-x64.rpm \[root@node1\]\# ls /usr/java \[root@node1\]\# vim /etc/profile.d/jdk.sh \#JDK export JAVA\_HOME=/usr/java/jdk1.8.0\_144 export JRE\_HOME=/usr/java/jdk1.8.0\_144/jre export CLASSPATH=$CLASSPATH:$JAVA\_HOME/lib:$JAVA\_HOME/jre/lib export PATH=$JAVA\_HOME/bin:$JAVA\_HOME/jre/bin:$PATH:$HOMR/bin **MAVEN安装:** \[root@node1\]\# tar xf /Mysources/apache-maven-3.5.0-bin.tar.gz \[root@node1\]\# vim /etc/profile.d/maven.sh \#MAVEN export MAVEN\_HOME=/opt/Moxiang/apache-maven-3.5.0 export PATH=$MAVEN\_HOME/bin:$PATH **Jenkins安装:** 下载jenkins的war包,直接放在tomcat/webapps/下。启动tomcat 即可。 下载地址:[https://jenkins.io/download][https_jenkins.io_download] ,下载通用的java包即可。 修改默认的路径: 方法一: echo “export JENKINS\_HOME=/data/jenkins-home” >/etc/profile.d/jenkins.sh 方法二: 使用你Web容器的管理工具设置JENKINS\_HOME环境参数. 打开tomcat的bin目录,编辑catalina.sh文件。 在\# OS specific support. $var \_must\_ be set to either true or false.上面添加:export JENKINS\_HOME="/jenkins" 浏览器输入:ip:port/jenkins 。输入密码 密码保存位置: /root/.jenkins/secrets/initialAdminPassword ![image.png][] ![image.png][image.png 1] ![image.png][image.png 2] **安装maven插件** 在“系统管理”—>“管理插件”—>“可选插件”,安装 “Maven Release Plug-in ”. ** 全局工具配置:**配置JDK,MAVEN的home,配置GIT的命令路径 ![image.png][image.png 3] ![image.png][image.png 4] ![image.png][image.png 5] **构建一个maven风格的任务:** ![image.png][image.png 6] 将公钥复制到码云上,即可 转载于:https://blog.51cto.com/pizining/2108585 [https_jenkins.io_download]: https://jenkins.io/download [image.png]: https://s1.51cto.com/images/20180427/1524818855876657.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk= [image.png 1]: https://s1.51cto.com/images/20180427/1524818879752590.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk= [image.png 2]: https://s1.51cto.com/images/20180427/1524818893540298.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk= [image.png 3]: https://s1.51cto.com/images/20180427/1524819448249805.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk= [image.png 4]: https://s1.51cto.com/images/20180427/1524819467321487.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk= [image.png 5]: https://s1.51cto.com/images/20180427/1524819478740836.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk= [image.png 6]: https://s1.51cto.com/images/20180427/1524819671620726.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=
还没有评论,来说两句吧...