提交 c580f5d5 编写于 作者: mydemo4's avatar mydemo4

删除TOOL

上级 d5b19cd8
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#assign ibizsys_base_file = '${pub.getPSApplication().getPFType()}'>
<#if pub.getPSApplication().getPSPFStyle().getVersionString()?? && (pub.getPSApplication().getPSPFStyle().getVersionString()!='')>
<#assign ibizsys_base_file += '-${pub.getPSApplication().getPSPFStyle().getVersionString()}'>
</#if>
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import git
import time
import sys
import os
import pycurl
import platform
import jenkins
from ReadProperties import Properties
if(sys.argv[1]=='begin' or sys.argv[1]=='rebuild'):
#初始化GIT目录
if(platform.system()=="Linux"):
pro = Properties('${codefolder}/${sys.getPSDevCenterDomain()}/${sys.getPubSystemId()}/${sys.getVCName()}/.TOOL/repo.properties').getProperties()
else:
pro = Properties('${codefolder}\\${sys.getPSDevCenterDomain()}\\${sys.getPubSystemId()}\\${sys.getVCName()}\\.TOOL\\repo.properties').getProperties()
git_user = pro["git_user"]
git_pass = pro["git_pass"].replace("@", "%40")
git_path = pro["git_path"]
#git_path = pro["git_path"].replace("//", "//" + git_user + ":" + git_pass + "@")
#git_api = git_path+"/api/v4/projects"
#git_repo = git_path+"/"+git_user+"/${sys.codeName}"
git_repo = git_path
if(platform.system()=="Linux"):
git_local = "${codefolder}/${sys.getPSDevCenterDomain()}/${sys.getPubSystemId()}/${sys.getVCName()}/${sys.codeName}"
else:
git_local = "${codefolder}\\${sys.getPSDevCenterDomain()}\\${sys.getPubSystemId()}\\${sys.getVCName()}\\${sys.codeName}"
if os.path.exists(git_local+os.sep+".git"):
repo = git.Repo(path=git_local)
repo.git.config("user.name",git_user)
repo.git.config("user.email",git_user)
repo.git.fetch("--all")
repo.git.reset('--hard','origin/master')
else:
#c = pycurl.Curl()
#c.setopt(c.URL, git_api) # (网址)
#c.setopt(c.HTTPHEADER, ["PRIVATE-TOKEN: axMxnfp_oyYpDGp-rP4J"]) # 网址头部
#c.setopt(c.POST, 1) # 1表示调用post方法而不是get
#c.setopt(c.POSTFIELDS, "name=${sys.codeName}") # 数据
#c.setopt(c.CONNECTTIMEOUT, 60) # 超时中断
#c.setopt(c.TIMEOUT, 600) # 下载超时
#c.perform() # 提交
if(platform.system()=="Linux"):
repo = git.Repo.clone_from(url=git_repo, to_path="${codefolder}/${sys.getPSDevCenterDomain()}/${sys.getPubSystemId()}/${sys.getVCName()}/${sys.codeName}")
else:
repo = git.Repo.clone_from(url=git_repo, to_path="${codefolder}\\${sys.getPSDevCenterDomain()}\\${sys.getPubSystemId()}\\${sys.getVCName()}\\${sys.codeName}")
repo.git.config("user.name",git_user)
repo.git.config("user.email",git_user)
if(sys.argv[1]=='rebuild'):
if os.path.exists(git_local+os.sep+".git"):
flag=False
rootdir = git_local
for root,dirs,files in os.walk(r,rootdir):
for i in files:
path = os.path.join(root,i)
if os.path.isfile(path) and path.find(".git")==-1:
edituser=repo.git.log(path).split("\n")[1].split(" ")[1]
if edituser=="" or edituser==git_user:
flag=True
repo.git.rm(path)
if flag:
repo.git.commit("-m 123")
repo.git.push("origin", "master")
#创建目录
if(platform.system()=="Linux"):
os.system(r"mkdir -p ${codefolder}/${sys.getPSDevCenterDomain()}/${sys.getPubSystemId()}/${sys.getVCName()}/${sys.codeName}/app_${pub.getPSApplication().getPKGCodeName()}")
else:
os.system(r"mkdir -p ${codefolder}\${sys.getPSDevCenterDomain()}\${sys.getPubSystemId()}\${sys.getVCName()}\${sys.codeName}\app_${pub.getPSApplication().getPKGCodeName()}")
#拷贝初始文件
if(platform.system()=="Linux"):
os.system(r"cp -p -rf ${toolfolder}/APP/${ibizsys_base_file}/APP/ ${codefolder}\${sys.getPSDevCenterDomain()}\${sys.getPubSystemId()}\${sys.getVCName()}\${sys.codeName}\app_${pub.getPSApplication().getPKGCodeName()}/")
else:
os.system(r"xcopy ${toolfolder}\APP\${ibizsys_base_file}\APP\*.* ${codefolder}\${sys.getPSDevCenterDomain()}\${sys.getPubSystemId()}\${sys.getVCName()}\${sys.codeName}\app_${pub.getPSApplication().getPKGCodeName()} /I/E/Y/D")
if(sys.argv[1]=='end'):
if(platform.system()=="Linux"):
pro = Properties('${codefolder}/${sys.getPSDevCenterDomain()}/${sys.getPubSystemId()}/${sys.getVCName()}/.TOOL/repo.properties').getProperties()
else:
pro = Properties('${codefolder}\\${sys.getPSDevCenterDomain()}\\${sys.getPubSystemId()}\\${sys.getVCName()}\\.TOOL\\repo.properties').getProperties()
git_user = pro["git_user"]
git_pass = pro["git_pass"].replace("@", "%40")
git_path = pro["git_path"]
#git_path = pro["git_path"].replace("//", "//" + git_user + ":" + git_pass + "@")
if(platform.system()=="Linux"):
repo = git.Repo(path="${codefolder}/${sys.getPSDevCenterDomain()}/${sys.getPubSystemId()}/${sys.getVCName()}/${sys.codeName}")
else:
repo = git.Repo(path="${codefolder}\\${sys.getPSDevCenterDomain()}\\${sys.getPubSystemId()}\\${sys.getVCName()}\\${sys.codeName}")
flag=False
for i in (repo.git.status("-s").split("\n")):
if i.startswith(" M"):
flag = True
editfile=i.split(" ")[2]
edituser=repo.git.log(editfile).split("\n")[1].split(" ")[1]
print("***"+edituser+"****")
if edituser=="" or edituser==git_user:
repo.git.add(editfile,"-f")
elif i.startswith("??"):
flag = True
editfile = i.split(" ")[1]
repo.git.add(editfile, "-f")
if flag:
repo.git.commit("-m 123")
repo.git.push("origin", "master")
if(len(sys.argv)==3 and sys.argv[2]=='STARTMSAPP'):
if(platform.system()=="Linux"):
config = '${codefolder}/${sys.getPSDevCenterDomain()}/${sys.getPubSystemId()}/${sys.getVCName()}/.TOOL/config.xml'
else:
config = '${codefolder}\\${sys.getPSDevCenterDomain()}\\${sys.getPubSystemId()}\\${sys.getVCName()}\\.TOOL\\config.xml'
jenkins_url = "http://172.16.102.22:8080/jenkins"
jenkins_userid = "admin"
jenkins_apitoken = "07e8e656612a8e1b5508875a0da80187"
server = jenkins.Jenkins(jenkins_url, username=jenkins_userid, password=jenkins_apitoken)
jobname = '${sys.getPubSystemId()}'
#初始化JOB配置
try:
server.assert_job_exists(jobname, exception_message='job %s does not exist.......')
except jenkins.JenkinsException as e:
with open(config) as f:
profile = f.read()
server.create_job(jobname, profile)
with open(config) as f:
profile = f.read()
server.reconfig_job(jobname, profile)
#触发构建
server.build_job(jobname)
number = server.get_job_info(jobname)['nextBuildNumber']-1
while True:
result=server.get_build_console_output(jobname,number)
if 'Finished: SUCCESS' in result or 'Finished: FAILURE' in result:
print(result)
break
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册