You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

83 lines
2.5 KiB

# -*- coding: UTF-8 -*-
#此文件放到jenkins job下 用于更新svn 初始工程
import os
import sys
svn = os.environ.get("svn", "D:/soft/Apache-Subversion-1.10.3/bin/svn.exe")
branchName = "trunk"
notRevert = "false"
svn_share_proj_Path = "http://10.0.201.30:8011/svn/anhei/"
local_u2china_share_proj = "./trunk"
svn_client_proj_path = "http://10.0.201.30:8011/svn/anhei/"
local_u2c_client_proj = "./trunk"
basePath = os.getcwd()
svn_username=""
svn_password=""
def CheckoutSVN(sourcePath,branch,localPath):
ret = 0
if not os.path.exists(localPath):
command = svn + " checkout " + sourcePath + branch + " " + localPath + (''' --username {} --password {} '''.format(svn_username,svn_password))
print(svn + " checkout " + sourcePath + branch + " " + localPath)
else:
if notRevert == "false":
command = svn + " revert -R " + localPath
print(command)
ret = os.system(command)
if ret != 0:
print("revert error!")
exit(1)
#切换分支
command = svn + " switch " + sourcePath + branch + " " + localPath + (''' --username {} --password {} '''.format(svn_username,svn_password))
print(svn + " switch " + sourcePath + branch + " " + localPath)
ret = os.system(command)
if ret != 0:
print("checkout error!")
exit(1)
command = svn + " update " + localPath + (''' --username {} --password {} '''.format(svn_username,svn_password))
print(svn + " update " + localPath)
ret = os.system(command)
print(command)
if ret != 0:
print("update error!")
exit(1)
os.chdir(basePath)
print("update Finish " + localPath + "----branch : " + branch)
def UpdateShare(branch):
CheckoutSVN(svn_share_proj_Path,branch,local_u2china_share_proj)
def CheckoutClientProj(branch):
CheckoutSVN(svn_client_proj_path,branch,local_u2c_client_proj)
if __name__ == '__main__':
if len(sys.argv) > 2:
branchName = sys.argv[1]
checkoutProj = sys.argv[2]
if len(sys.argv) > 3:
svn = sys.argv[3]
if len(sys.argv) > 4:
notRevert = sys.argv[4]
if len(sys.argv) > 5:
svn_username = sys.argv[5]
if len(sys.argv) > 6:
svn_password = sys.argv[6]
else:
print("param is error!")
exit(1)
if checkoutProj == "all":
CheckoutClientProj(branchName)
elif checkoutProj == "share":
UpdateShare(branchName)
else:
print("checkoutProj is error!")
exit(1)