From 393b2655f107a008474962bab0bd46ee28f0421c Mon Sep 17 00:00:00 2001 From: SoonKyu Park Date: Mon, 4 Dec 2017 18:49:16 +0900 Subject: [PATCH] Update job_update_gbs_meta.py It can be triggered by 'create-snapshot -> git-ref-mapping-update -> update-gbs-meta' Change-Id: I577305fccbb8ec1c7fc195890e9604eda0f36bb7 --- job_update_gbs_meta.py | 54 +++++++++----------------------------------------- 1 file changed, 9 insertions(+), 45 deletions(-) diff --git a/job_update_gbs_meta.py b/job_update_gbs_meta.py index 1096297..18865df 100755 --- a/job_update_gbs_meta.py +++ b/job_update_gbs_meta.py @@ -18,7 +18,6 @@ basic_url= os.getenv('URL_PUBLIC_REPO_BASE') + '/snapshots/tizen/' public_basic_url = 'http://download.tizen.org/snapshots/tizen/' daily_release_url= os.getenv('URL_PUBLIC_REPO_BASE') + '/releases/daily/tizen/' public_daily_release_url = 'http://download.tizen.org/releases/daily/tizen/' -public_daily_release_url = 'http://download.tizen.org/releases/daily/tizen/' gbs_meta_default_profile = os.getenv('GBS_META_DEFAULT_PROFILE') gbs_meta_support_tizen_ver = os.getenv('GBS_META_SUPPORT_TIZEN_VER') @@ -484,7 +483,7 @@ def _update_scm_manifest(ref_list,base_prj_list,commit_msg,is_staging): print '%s, branch %s has nothing to commit' %(git_prj,git_branch) -def prepare_ref_binary_by_git(event): +def prepare_ref_binary(event): """ prepare_ref_binary_by_git""" print "----------prepare_ref_binary_by_git start--------" @@ -512,33 +511,13 @@ def prepare_ref_binary_by_git(event): ref_binary[line.split('"')[1]] = line.split('"')[3] #Add default profile supported by gbs - for profile in gbs_meta_default_profile.split(' '): - ref_binary[profile]=profile+':ref:latest' + if gbs_meta_default_profile: + for profile in gbs_meta_default_profile.split(' '): + ref_binary[profile]=profile+':ref:latest' return (ref_binary,commit_msg) -def prepare_ref_binary_by_build_id(content): - """ prepare_ref_binary_by_build_id""" - print "----------prepare_ref_binary_by_build_id start--------" - ref_binary = {} - - support_obs_prj = os.getenv('SUPPORT_OBS_PRJ') - for obs_prj in support_obs_prj.split(' '): - path_prj = obs_prj.replace(':','-').lower() - url = basic_url + '/' + path_prj.replace('tizen-','') + '/' - print url - url_content=urllib2.urlopen(url).read() - build_id=0 - for snapshot_id in url_content.split(path_prj+'_')[1:]: - tmp_id=snapshot_id.split('/">')[0] - if tmp_id[-1] == '1' and tmp_id.split('.')[0] >= build_id: - build_id = tmp_id - ref_binary[obs_prj] = obs_prj+':ref:'+build_id - - return (ref_binary,content['build_id']) - - def main(): """script entry point""" @@ -554,7 +533,6 @@ def main(): # Otherwise, submit gbs meta files to original branch if 'project' in event and 'event_type' in event: print 'update-gbs-meta job is triggered by gerrit event' - triggered_by_snapshot_creation = 'false' is_staging = '_staging' if event['event_type'] != "ref-updated" or event['project'] != "scm/git-ref-mapping": # This is just a sanity check as ref-updated is the only event we @@ -568,25 +546,11 @@ def main(): print 'update-gbs-meta job is triggered by other jenkins job\n\ gbs-ref-fullbuild or create-snapshot' content = trigger_info(os.getenv("TRIGGER_INFO")) - if content["triggered_from"] == 'gbs_ref_fullbuild': - print 'update-gbs-meta job is triggered by gbs-ref-fullbuild' - triggered_by_snapshot_creation = 'false' - event = content['event'] - is_staging = '' - else: - print 'update-gbs-meta job is triggered by create-snapshot' - support_obs_prj = os.getenv('SUPPORT_OBS_PRJ') - if support_obs_prj.find(content['project']) == -1 or\ - content['build_id'][-1] != '1': - print 'update-gbs-meta is triggered only for first snapshot of %s' %support_obs_prj - return 1 - triggered_by_snapshot_creation = 'true' - is_staging = '_staging' - - if triggered_by_snapshot_creation == 'false': - (ref_binary,commit_msg) = prepare_ref_binary_by_git(event) - else: - (ref_binary,commit_msg) = prepare_ref_binary_by_build_id(content) + print 'update-gbs-meta job is triggered by gbs-ref-fullbuild' + event = content['event'] + is_staging = '' + + (ref_binary,commit_msg) = prepare_ref_binary(event) print 'Each reference snapshot numbers are like below' print ref_binary -- 2.7.4