1、Jenkins Git集成
新建任务:
构建:
2、Jenkins maven集成
jenkins服务器安装maven:
[root@jenkins ~]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz [root@jenkins ~]# tar zxf apache-maven-3.6.3-bin.tar.gz -C /opt/ [root@jenkins ~]# cd /opt/apache-maven-3.6.3/bin/ [root@jenkins bin]# ./mvn --version Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /opt/apache-maven-3.6.3 ......
在gitlab上创建一个java项目:Java-war-dev
把本地准备好的java案例,提交到仓库中:
打开Git Bash,进入项目目录下: cd Java-war-dev/ git init git add . git status git config --global user.email "admin@example.com" git config --global user.name "admin" git commit -m"First commit" git remote add origin http://gitlab.example.com/root/java-war-dev.git git pull --rebase origin master git -c http.sslVerify=false push origin master
设置:
Manage Jenkins—>Configure Global Security:
配置jdk和maven:
Manage Jenkins—>Global Tool Configuration
新建任务:
应用,保存;
构建:
3、Jenkins ansible集成
jenkins主机上安装python3.5、virtualenv、ansible
添加deploy 用户,并配置到test.example.com主机的免密登录;
以上步骤参考:https://www.cnblogs.com/weiyiming007/p/12624079.html
添加ansible主机的清单文件:
[deploy@jenkins ~]$ cd [deploy@jenkins ~]$ vim testservers [testserver] test.example.com ansible_user=root
添加jenkins任务:
任务描述:
构建脚本:
应用&&保存
开始构建:
192.168.3.250 的主机名就是test.example.com