1.java官网下载jdk
2.使用sftp上传压缩包到linux
cd /usr/local/
mkdir java
cd java
put C:\Users\user\Downloads\jdk-8u171-linux-x64.tar.gz
3.解压缩
tar -xzvf jdk-8u171-linux-x64.tar.gz
4.设置环境变量
vi /etc/profile
export JAVA_HOME=/usr/local/java/jdk1.8.0_171
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
5.刷新环境变量生效
source /etc/profile
6.验证
java -version
1.安装maven,官网下载maven压缩包
2.使用sftp上传压缩包到linux
cd /usr/local/
mkdir maven
cd maven
put C:\Users\user\Downloads\apache-maven-3.5.4-bin.tar.gz
3.解压缩
tar -xzvf apache-maven-3.5.4-bin.tar.gz
4.设置环境变量
vi /etc/profile
export MAVEN_HOME=/usr/local/maven/apache-maven-3.5.4
export MAVEN_HOME
export PATH=$PATH:$MAVEN_HOME/bin
5.刷新环境变量生效
source /etc/profile
6.验证
mvn -version
安装git 略
1.注册用户名,生成公钥私钥
git config --global user.name "junjunye.aliyun"
git config --global user.email "519291499@qq.com"
ssh-keygen -t rsa -C “junjun.ye@aliyun.com”
2.查看公钥把公钥提交到码云
cat ~/.ssh/id_rsa.pub
3.查看私钥,准备提供给jenkins
cat ~/.ssh/id_rsa
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEA6qzPYxit+XpJpLEYiuCdA559Jpn80c7qd2gO5qGV453ciFgL
cwTSeKj1HKanzGNT3OzaWtAwNTl1WIibZTbvTRf2cPCzJAShuCv3HFvszjF42Vsi
iPoD9MwCQv/Nt+Fifxuy3WjRGfaJBZEDMbAhqEr6t85bieDvK/qxaZ3G/XHDYID5
ejHAFeyMKN/2nd+tNZM+4wHffCcpePXYXb6ujuoFxCTZDmkn1QdnSVeNelvqN0/0
uQRpK/DATyYYR7JFZ7AxAlIcKchpkQliFe7AaXTdTkdAG5faGXp1p70W6QFs1FPC
uobODm+6d/94tNbIKZRpbP2dyeg+jycOMtVjvwIDAQABAoIBACqUTlCpoq9YW9JQ
+6X/GR4V/JkraW7b/zjJHaMFAIA7HU9zwigNYO7ZoReguWNhRk8YfonpqkWN9leo
+aEEtaikR2e4lJhdasZS29Q+bZn/6fBuE7cMvfkFpwdnCHlroIZ1jR+VLBNs4vGq
nQy/62twp0sAWyWKNXsiUlxab0d+qsWAl/8l+qQo/JtKpNemtVXYo2lOz4Cyr3JP
r1RoBvJGDKXIZPuJQwzHX+A7EiqqDjYcFynWJPryS2lNQ6a+ptUVOL24l/tnv5Eh
9QyNr38hhBCEFkKj2cl8/n7eDCKAW7SGFDmHGA98QZ/1PwOjnUGQDS6uAa5dvCDv
W5iZDjjLbpSE+4dXjqUwaqpP5W2g7id8GTNQXcMCgYBOXTFz6FwzsOD+0r5pxRpd
C8V/OcXXZZza4A9VG0nvlz64C4fYYvqZ9ZdPHGV171CUQUggydknGMbl0Ik6RCkt
/vGVVi7Khi/FwuolxsRWPsrOabquVCadzzsTOUFcbeUBiQcfv74vKjKepS9UTz/d
yfh9bZ3s0tGs4yx74qKn5QKBgBCJ3dEP1fFo5E/YnXll3ud3UvDR2oXfe7LjKQl9
fBJo21egW2LFUXr7YiDmI6CINhfHHL25Dirk8pceIjv6XWKKZaQrXcMF5RHLWi0t
QL/P87veFsgc78LiNN2e4+F7KhpTQrQ01UePb7NT1LHBDZiz71OTkPbT8kOAaLCu
tOLPAoGBALTkvnYo8psZ8x4OLTjkC0NIPNf2IiLSrJILmeajJ98QM6MFzMY02KFE
PZnoumPpaj2HIbt2UTcHDpBVl3nkeDcX9vGKuMghcEgTHogRbqyhw6z5KTwLbVTc
Om8vj2uC5I5Sl9wwIhvOAcgAFid4K4XNaHrQaAJUCiC0KI2xqFyg
-----END RSA PRIVATE KEY-----
4.验证git是否能从代码库拉取代码
git clone 。。。。。。
安装tomcat
1.tomcat官网下载tomcat
2.使用sftp上传压缩包到linux
cd /usr/local/
mkdir tomcat
cd tomcat
put C:\Users\user\Downloads\apache-tomcat-8.5.31.tar.gz
3.解压缩
tar -xzvf apache-tomcat-8.5.31.tar.gz
4.更改tomcat端口号为9999
vi server.xml
把8080端口号改为9999
5.tomcat user里添加用户,用于jenkins里的代码启动热部署
vi tomcat-users.xml
<role rolename="admin" />
<role rolename="admin-gui" />
<role rolename="manager" />
<role rolename="manager-script" />
<role rolename="manager-gui" />
<user username="admin" password="123456" roles="admin,manager,manager-script,manager-gui,admin-gui"/>
6.启动tomcat,注意,一定要启动,否则jenkins将无法热部署
bin目录下
sh startup.sh
7.验证tomcat是否启动成功
ps -ef|grep tomcat
安装jenkins
1.官网下载jenkins包
2.使用sftp上传压缩包到linux
cd /usr/local/
mkdir jenkins
cd jenkins
put C:\Users\user\Downloads\jenkins-2.128-1.1.noarch.rpm
3.安装jenkins
rpm -ivh jenkins-2.128-1.1.noarch.rpm
4.指定jenkins java路径 并修改jenkins权限为root
vi /etc/init.d/jenkins
修改文件里面的新增如下红字内容
Search usable Java as /usr/bin/java might not point to minimal version required by Jenkins.
see http://www.nabble.com/guinea-pigs-wanted-----Hudson-RPM-for-RedHat-Linux-td25673707.html
candidates="
/etc/alternatives/java
/usr/lib/jvm/java-1.8.0/bin/java
/usr/lib/jvm/jre-1.8.0/bin/java
/usr/lib/jvm/java-1.7.0/bin/java
/usr/lib/jvm/jre-1.7.0/bin/java
/usr/bin/java
/usr/local/java/jdk1.8.0_171/bin/java
"
for candidate in $candidates
do
[ -x "$JENKINS_JAVA_CMD" ] && break
JENKINS_JAVA_CMD="$candidate"
done
vi /etc/sysconfig/jenkins
修改
JENKINS_USER="root"
5.启动jenkins
sudo service jenkins start
6.验证jenkins是否启动
ps -ef|grep jenkins
7.网页进入配置jenkins
初始化解锁
8.无脑安装推荐插件
9.创建管理员用户,注意,此处会创建失败(应该是用了.特殊字符,直接注册就好),先以admin账户登录
10.保存并完成
11.打开允许注册设置并勾选登录用户可以做任何事,注销登录,然后创建一个用户
13.选择安装创建maven项目插件和发布到容器(tomcat)插件
https://wiki.jenkins.io/display/JENKINS/Maven+Project+Plugin
https://wiki.jenkins.io/display/JENKINS/Deploy+Plugin
安装以上两个插件之后,重启jenkins
http://ip:8080/restart
注意不要勾选自动安装
16.配置tomcat账户
同13.不过选择账户密码,填写之前tomcat里面配置的账户密码
配置源码管理配置git下载地址和之前设置的sshkey账户
构建后操作,自行筛选匹配war包,应用启动之后的路径目录,选中刚才添加的tomcat账户,本地tomcat地址(确保tomcat在运行!)和端口号,
18.立即构建!!!终于
原文地址请戳这里