From: hyokeun Date: Tue, 11 Apr 2017 01:38:10 +0000 (+0900) Subject: Update test information on target branch X-Git-Tag: submit/trunk/20190927.012743~483^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3a7a9daa56595bda6b6f7aa943178dba80e36ab0;p=services%2Fjenkins-scripts.git Update test information on target branch Receiver can determine which branch the prerelease comes from. For example, in case of Tizen:4.0 it will be "tizen". Change-Id: Id480f1fbbe06eebc5d4d63dcfa48311a5a0b02c0 --- diff --git a/job_test_trigger_info_update.py b/job_test_trigger_info_update.py index 7184e0f..44bfd57 100644 --- a/job_test_trigger_info_update.py +++ b/job_test_trigger_info_update.py @@ -16,11 +16,14 @@ import os import sys import json +import re from common.buildtrigger import trigger_info from common.git import Git, clone_gitproject from common.prerelease import is_prerelease_project +from gbp.git.args import GitArgs + GIT_FILE_NAME = 'prerelease.description' class LocalError(Exception): @@ -44,6 +47,18 @@ def main(): print '%s is not prerelease project' % project return 1 + try: + target_project, branch = \ + re.search(r'home:prerelease:(.*):submit:(.*):[0-9]{8}.[0-9]{6}', \ + project).groups() + except Exception as err: + raise LocalError('Cannot determine target branch (%s)' % err) + + #TODO: tizen_{profile}_tpk branch hack + if branch.endswith('_tpk'): + branch = branch.split('_%s_tpk' % target_project.split(':')[-1].lower())[0] + print 'We have [%s] [%s]' % (target_project, branch) + prjdir = os.path.join(os.getenv('WORKSPACE'), \ os.path.basename(os.getenv('TEST_TRIGGER_GIT_PATH'))) @@ -53,7 +68,13 @@ def main(): return 2 mygit = Git(prjdir) - mygit.checkout('master') + if mygit.has_branch('origin/' + branch, remote = True): + mygit.checkout(branch) + else: + args = GitArgs('--orphan', branch) + mygit._git_command('checkout', args.args) + args = GitArgs('-rf', '.') + mygit._git_command('rm', args.args) if os.path.exists(os.path.join(prjdir, GIT_FILE_NAME)): mygit.remove_files(GIT_FILE_NAME) with open(os.path.join(prjdir, GIT_FILE_NAME), 'w') as mf: @@ -61,7 +82,7 @@ def main(): mygit.add_files(GIT_FILE_NAME, True) try: mygit.commit_staged('%s' % project) - mygit.push(repo = 'origin', src = 'master') + mygit.push(repo = 'origin', src = branch) except Exception as err: print '\n** Commit or push to git error, %s\n' % err return 4