#!/usr/bin/python
import sys, time
import shutil, commands
#coding=utf-8
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import jenkins

config_file = 'jenkins_list.txt'
jenkins_url='http://qc-xxx.xxxx.com/'
user_name='user'
pass_word='password'
server = jenkins.Jenkins(jenkins_url, username=user_name, password=pass_word)
temp_job_name='saas-kf-aal-online'
tem_xml_file='tem.xml'

#print server.get_whoami()

#server.copy_job("xx-xx-xx-online", "xx-xx-copy-xxx-online")
#print server.get_job_info("saas-kf-copy-aal-online", depth=2, fetch_all_builds=True)
#print server.get_job_config("saas-kf-copy-aal-online")
#with open('aa.xml', 'r') as xml_file:
# config_data = xml_file.read()
#server.reconfig_job("saas-kf-copy-aal-online",config_data)

def commands_shell(cmd):
(status, output) = commands.getstatusoutput(cmd)
print status, output
return status, output

file = open(config_file)

while 1:
line = file.readline()
if not line:
break
line_str = line.split(',')
job_name = line_str[0].strip()
git_url = line_str[1].strip()
target_dir = line_str[2].strip()
job_name_xml='job_name/' + job_name + '.xml'
print job_name,git_url
##copy tem file
shutil.copy(tem_xml_file, job_name_xml)
cmd = "sed -i 's#TMPGITURL#%s#g' %s" % (git_url, job_name_xml)
print cmd
ret = commands_shell(cmd)

print ret
cmd = "sed -i 's#TARGET_DIR#%s#g' %s" % (target_dir, job_name_xml)

ret = commands_shell(cmd)
print ret

config_data = ''
with open(job_name_xml, 'r') as xml_file:
config_data = xml_file.read()
#server.reconfig_job("saas-kf-copytests-aal-online",config_data)
server.create_job(job_name, config_data)

file.close()

最新文章

  1. js实现简单的图片轮播
  2. cookie 和session 的区别详解
  3. KVM 基本命令
  4. TP中关于自定义类库的添加和使用
  5. WinPhone学习笔记(二)——页面外观剖析
  6. 读懂Android项目结构目录
  7. 安装 Oracle P6 EPPM 16 R1 database for 12C
  8. python线程使用场景 多线程下载
  9. GitHub 教程 in Ubuntu
  10. python def说明
  11. centos 下搭建 php环境(2) mysql 安装
  12. lightoj 1064 Throwing Dice
  13. [C#基础] 类
  14. Android之触摸手势检测GestureDetector使用详解
  15. ARP协议与ARP攻击入门
  16. 从零开始学习PYTHON3讲义(六)for循环跟斐波那契数列
  17. [Oracle]使用InstantClient访问Oracle数据库
  18. 快速上手Git
  19. Qt编写自定义控件7-自定义可拖动多边形
  20. 在vscode成功配置Python环境

热门文章

  1. RabbitMQ消息中间件的用法
  2. pom文件语法无误却报红叉(Unknown error)的可能原因
  3. java -- Set 用法及特点
  4. C# 调用打印机打印文件
  5. JavaScript的Proxy可以做哪些有意思的事儿
  6. CDH报错:ScmActive at bootup: Failed to validate the identity of Cloudera Manager.
  7. JAVA concurrent包下Semaphore、CountDownLatch等用法
  8. Python从零开始——基础语法
  9. 修改GIT已提交的用户名和邮箱
  10. Nginx 高级配置--关于favicon.ico