Jenkins Ant 自动编译部署测试环境

Jenkins Ant 自动编译部署测试环境

2019.06.29 13:40:45字数 396阅读 56

1、配置密钥

1.1 注册用户

1.1.1 配置域名解析

// 1、Windows 系统:
// 打开 C:WindowsSystem32driversetc 目录下的 hosts 文件
// 添加如下内容:
192.168.xxx.1 gitlab.oceanpayment.com

// 2、Linux 系统:
// 输入命令
vim /etc/hosts
// 添加如下内容:
192.168.xxx.1 gitlab.oceanpayment.com

1.1.2 登录 Gitlab

 

1.1.3 注册用户

 
1.2 jenkins 服务器上相关用户生成密钥对

1、输入命令,生成密钥对:$ ssh-keygen -t rsa

Generating public/private rsa key pair.
    // 直接按回车键
    Enter file in which to save the key (/home/weblogic/.ssh/id_rsa):
    // 输入密码 test2018
    Enter passphrase (empty for no passphrase):
    // 输入确认密码
    Enter same passphrase again:
    // 生成的密钥路径
    Your identification has been saved in /home/weblogic/.ssh/id_rsa.
    Your public key has been saved in /home/weblogic/.ssh/id_rsa.pub.
    The key fingerprint is:
        65:cc:ab:3e:75:fb:00:a1:35:50:a4:87:dc:50:cb:e3 [weblogic@weblogic-test2.localdomain](mailto:weblogic@weblogic-test2.localdomain)

1.3 设置 gitlab 密钥

1、输入命令,查看公钥:$ cat /home/weblogic/.ssh/id_rsa.pub

 

2、添加 gitlab 密钥

 
 
1.4 设置 jenkins 密钥

1、输入命令,查看私钥:$ cat /home/weblogic/.ssh/id_rsa

 

2、添加 Jenkins 密钥

 
 
 
 
 

2、Ant 配置

2.1 Ant 官网

http://ant.apache.org/bindownload.cgi

2.2 解压 Ant 安装包

1、解压命令:
tar -vxzf apache-ant-1.9.11-bin_jdk1.7.tar.gz

2、Ant目录:cd /usr/local

 

3、Ant 对应 jdk 版本
apache-ant-1.10.3 对应 jdk1.8
apache-ant-1.9.11 对应 jdk1.7

2.3 更改权限

1、输入以下命令:
chmod -R +x apache-ant-1.9.11

2.4 修改系统配置文件

1、使用 vim 打开系统配置文件:
vim /etc/profile

2、添加以下内容:

# 设置 java enviroment
export PATH=$PATH:$HOME/bin:/home/weblogic/jdk1.7.181/bin
JAVA_HOME=/home/weblogic/jdk1.7.181

# 设置 Ant enviroment
export ANT_HOME=/usr/local/apache-ant-1.9.11
export PATH=$PATH:$JAVA_HOME/bin:$ANT_HOME/bin

3、立刻将配置生效
source /etc/profile

4、测试 ant 是否生效
ant -version

3、Jenkins 自动编译部署

3.1 Jenkins 插件
 
 
3.2 全局配置

1、系统管理 -> Global Tool Configuration,设置如下信息:

 
 
 
3.3 配置 Git、Ant 自动编译部署

1、设置 General

 

2、设置源码管理

 

3、设置环境构建

 

4、设置构建

 
 
 

5、Ant 编译配置文件

1、路径:/home/weblogic/AutoBuild/Ant/config/build_simple.xml
2、文件内容如下:

 
原文地址:https://www.cnblogs.com/tsgxj/p/11571858.html