jenkins svn同步
a,开发人员通过svn 提交代码到指定的的服务器A。
b,测试服务器B搭建jenkins,同时配置远程svn服务器,更新代码到指定D盘a目录下(a目录下用于更新服务的代码)
然后通过jenkins里的同步程序,同步到D盘b目录下(b盘目录是测试服务器目录)。
配置同步的时间
c,通过访问测试服务器B,就可以看到更新后的程序
1. 下载jenkins war 包
2. 下载jdk :环境安装
3. 下载python :执行同步用到
4. cmd 执行 java -jar D:\jdk\jenkins.war
5. 登录 localhost:8080
6. 新建item New Item ,输入任务名称(enter a task name), 选择 (Freestyle project)
7. Manage Jenkins -> Manage Plugins -> Optional plugin 安装 Subversion
8. 在新建项目 new item 配置里 General 输入描述;
源码管理选择:Subversion;Repository URL:选择指定svn的地址 Repository URL https://desktop-ibib68r:444/svn/Test/fun@HEAD credentials
选择svn用户名和密码;Check-out Strategy:选择Emulate clean checkout by first...; 构建触发器Build trigger:选择Build periodically ;
schedule:输入需要执行任务的时间:H/1 * * * *; (代替方法: Build trigger:勾选:Trigger a remote build (for example, using a script);
填写 Authentication token:123456789;勾线 Poll SCM,填写schedule:* * * * *)
9.Construct:选择 execute windows bath command : command python
D:\jetbrainscrack\command.py
内容如下: ##################### #
-*- coding: UTF-8 -*- import os copyFileCounts = 0 # 目录复制 def copyFiles(sourceDir, targetDir): global copyFileCounts for f in os.listdir(sourceDir): sourceF = os.path.join(sourceDir, f) targetF = os.path.join(targetDir, f) if os.path.isfile(sourceF): # 创建目录 if not os.path.exists(targetDir): os.makedirs(targetDir) copyFileCounts += 1 # 文件不存在,或者存在但是大小不同,覆盖 if not os.path.exists(targetF) or (os.path.exists(targetF) and (os.path.getsize(targetF) != os.path.getsize(sourceF))): # 2进制文件 open(targetF, "wb").write(open(sourceF, "rb").read()) if os.path.isdir(sourceF): copyFiles(sourceF, targetF) if __name__ == "__main__": copyFiles("D:/aa", "D:/bb") #####################
10.Use a custom workspace table of Contents D:\test (自定义workspace的目录,也是svn提交之后,会把提交的代码同步这个目录)
11.在Manage Jenkins界面下载jenkins-cli.jar,放在指定的目录
12.配置Configure Global Security,cmd执行命令 Authorization strategy =>Anyone can do anything proxy TCP port for inbound agents =>Randomly selected
13.提交svn cmd 执行 java -jar d:/jdk/jenkins-cli.jar -s http://localhost:8080/ build 测试环境
14,配置浏览器刷新 Build trigger Trigger a remote build (for example, using a script) Authentication token 填写token 123456789
15.浏览器执行:http://127.0.0.1:8080/job/测试环境/build?token=123456789,也可以将提交的svn 更新到本地 Build periodically H/1 * * * *
16,更改 构建触发器:Build trigger:勾选:Trigger a remote build (for example, using a script);填写 Authentication token:123456789;勾线 Poll SCM,填写schedule:* * * * * svn 提交代码,自动构建,将代码同步到测试环境
jenkins svn同步
最新推荐文章于 2024-04-29 12:25:48 发布