def assemble(): clean_command = "cd %s && ./gradlew clean" % demo_path result = aries_util.doSubprocess(clean_command) if result['status'] == CONFIG_CONST.FAIL_STATUS: return result assemble_command = "cd %s && ./gradlew assembleRelease" % demo_path return aries_util.doSubprocess(assemble_command)
def submodule_update(branch): print '更新submodule...' if branch.startswith("origin/"): branch = branch[7:] # modify_branch_command = '''sed -i "s/branch = .*/branch = %s/g" .gitmodules''' % branch modify_branch_command = 'cd %s && git config -f .gitmodules submodule.CIDemo_AppShell.branch %s' % ( demo_path, branch) result = aries_util.doSubprocess(modify_branch_command) if result['status'] == CONFIG_CONST.FAIL_STATUS: return result update_command = "cd %s && git submodule update --init --recursive --remote" % demo_path result = aries_util.doSubprocess(update_command) return result
def modify_gradle(updatemodules): print 'modify module version...' for data in updatemodules: pattern = 'com.zwy.cidemo:%s:' % (data['moduleName']) # sed:-i表示直接修改源文件:sed -i 's/替换前/替换后/g' 文件名 / /中间是正则表达式 # com.zwy.cidemo:module_girls:1.0.4 print 'found dependence...' found_command = '''sed -n "/%s/p" dependencies.gradle''' % pattern result = aries_util.doSubprocess(found_command) if result['status'] == CONFIG_CONST.FAIL_STATUS: return result if data['type'] == LINK_TYPE['REMOVE_MODULE']: result = remove_implementation(pattern) else: if len(result['output']) == 0: result = add_implementation(pattern, data['version']) else: result = modify_implementation(pattern, data['version']) if result['status'] == CONFIG_CONST.FAIL_STATUS: return result return result
def upload_maven(module_name): print 'upload maven...' upload_command = './gradlew :%s:upload' % module_name return aries_util.doSubprocess(upload_command)
def modify_build_version(module_name, build_version): print 'modify build version...' # sed:-i表示直接修改源文件:sed -i 's/替换前/替换后/g' 文件名 modify_command = '''sed -i "s/version '.*'/version '%s'/g" %s/upload_nexus.gradle''' % ( build_version, module_name) return aries_util.doSubprocess(modify_command)
def modify_sdk_path(): print 'modify sdk path...' modify_command = '''sed -i "s/sdk.dir=.*/sdk.dir=\\/var\\/android_sdk/g" local.properties''' return aries_util.doSubprocess(modify_command)
def remove_implementation(pattern): print 'remove implementation...' remove_command = '''sed -i "/%s/d" dependencies.gradle''' % pattern result = aries_util.doSubprocess(remove_command) return result
def modify_implementation(pattern, version): print 'modify implementation...' modify_command = '''sed -i "s/'%s.*'/'%s'/g" dependencies.gradle''' % (pattern, pattern + version) result = aries_util.doSubprocess(modify_command) return result
def add_implementation(pattern, version): print 'add new implementation...' add_command = '''sed -i "1a \ '%s'," dependencies.gradle''' % (pattern + version) result = aries_util.doSubprocess(add_command) return result
def upload_apk(): apk_name = find_apk() apk_path = demo_path + "/CIDemo_AppShell/build/outputs/apk/release/%s" % apk_name upload_command = '''curl -F "file=@%s" -F "uKey=%s" -F "_api_key=%s" https://qiniu-storage.pgyer.com/apiv1/app/upload''' % ( apk_path, u_key, api_key) return aries_util.doSubprocess(upload_command)