From fd04dde40cdc90c53ff25df16309635076b697c1 Mon Sep 17 00:00:00 2001 From: SoonKyu Park Date: Fri, 13 Oct 2017 14:54:16 +0900 Subject: [PATCH] Change job order of 'gbs-ref-fullbuild' and 'update-gbs-meta' As-is : 1.Update git-ref-mapping 2.gbs-ref-fullbuild 3.update-gbs-meta New : 1.Update git-ref-mapping 2.update-gbs-meta(staging) 3.gbs-ref-fullbuild 4.update-gbs-meta Change-Id: I739a99fcfc9bdc6193721a5e721b5d0b8dae92a8 --- job_gbs_ref_fullbuild.py | 14 ++++++++--- job_update_gbs_meta.py | 61 +++++++++++++++++++++++++++++------------------- 2 files changed, 48 insertions(+), 27 deletions(-) diff --git a/job_gbs_ref_fullbuild.py b/job_gbs_ref_fullbuild.py index 43504ea..d436c46 100755 --- a/job_gbs_ref_fullbuild.py +++ b/job_gbs_ref_fullbuild.py @@ -12,7 +12,7 @@ import re from common.git import Git, clone_gitproject from common.gerrit import Gerrit, get_gerrit_event, GerritError, is_ref_deleted from common.buildservice import BuildService -from common.buildtrigger import trigger_next +from common.buildtrigger import trigger_info,trigger_next # prepare related global variables workspace = os.getenv('WORKSPACE') @@ -132,7 +132,10 @@ def _do_repo_init_sync(repo): repo_init_arg = ' -u https://git.tizen.org/cgit/scm/manifest' #add '-b' option - repo_init_arg += ' -b '+ref_profile['t_branch'] + #gbs fullbuild for staing branch first. + #If gbs fullbuild for staging branch, update gbs meta to original branch at next trigger +# repo_init_arg += ' -b '+ref_profile['t_branch'] + repo_init_arg += ' -b '+ref_profile['t_branch']+'_staging' #add '-m' option repo_init_arg += ' -m '+ref_profile['profile']+'_'+repo+'.xml' @@ -339,7 +342,9 @@ def main(): print '---[JOB STARTED]----------------------------------------' - event = get_gerrit_event() + #event = get_gerrit_event() + event = trigger_info(os.getenv("TRIGGER_INFO")) + # prepare separate temp directory for each build if event['event_type'] != "ref-updated" or event['project'] != "scm/git-ref-mapping": @@ -391,6 +396,7 @@ def main(): build_profile_list=list(set(build_profile_list)) print 'gbs fullbuild target profiles are :\n%s' %build_profile_list + original_dir=os.getcwd() for build_profile in build_profile_list: print 'gbs fullbuild start for build_profile: %s' %build_profile @@ -398,12 +404,14 @@ def main(): if SUPPORT_PROFILES.find(build_profile) == -1: print "skip fullbuild...\nGBS reference fullbuild is triggered only for %s" %SUPPORT_PROFILES + os.chdir(original_dir) trigger_next("update-gbs-meta",event) return 0 do_gbs_build() do_image_creation() + os.chdir(original_dir) # TRIGGER NEXT BUILD-MONITOR update_message="Succeeded" if len(update_message) < 119: diff --git a/job_update_gbs_meta.py b/job_update_gbs_meta.py index 0244e6b..a54c66d 100755 --- a/job_update_gbs_meta.py +++ b/job_update_gbs_meta.py @@ -9,7 +9,7 @@ import urllib2 import gzip from common.git import Git, clone_gitproject from common.gerrit import Gerrit, get_gerrit_event, GerritError, is_ref_deleted -from common.buildtrigger import trigger_info +from common.buildtrigger import trigger_info, trigger_next # prepare related global variables workspace = os.getenv('WORKSPACE') @@ -141,7 +141,7 @@ def _update_base_prj_index(): return base_prj_list -def _update_build_conf(ref_list,commit_msg): +def _update_build_conf(ref_list,commit_msg,is_staging): """ Update scm/meta/build-config after ref.binary update""" print "-----------------------------------------------------" print "Update scm/meta/build-config after ref.binary update" @@ -149,7 +149,7 @@ def _update_build_conf(ref_list,commit_msg): # prepare separate temp directory for each build git_prj = 'scm/meta/build-config' - git_branch="tizen" + git_branch="tizen"+is_staging tmpdir = tempfile.mkdtemp(prefix=workspace+'/') atexit.register(shutil.rmtree, tmpdir) @@ -200,7 +200,7 @@ def _update_build_conf(ref_list,commit_msg): print '%s, branch %s has nothing to commit' %(git_prj,git_branch) -def _update_gbs_conf(ref_list,base_prj_list,commit_msg): +def _update_gbs_conf(ref_list,base_prj_list,commit_msg,is_staging): """ Update scm/meta/gbs-config after ref.binary update""" print "-----------------------------------------------------" print "Update scm/meta/gbs-config after ref.binary update" @@ -208,7 +208,7 @@ def _update_gbs_conf(ref_list,base_prj_list,commit_msg): # prepare separate temp directory for each build git_prj = 'scm/meta/gbs-config' - git_branch="tizen" + git_branch="tizen"+is_staging tmpdir = tempfile.mkdtemp(prefix=workspace+'/') atexit.register(shutil.rmtree, tmpdir) @@ -322,7 +322,7 @@ def _update_gbs_conf(ref_list,base_prj_list,commit_msg): print '%s, branch %s has nothing to commit' %(git_prj,git_branch) -def _update_scm_manifest(ref_list,base_prj_list,commit_msg): +def _update_scm_manifest(ref_list,base_prj_list,commit_msg,is_staging): """ Update scm/manifest after ref.binary update""" print "-----------------------------------------------------" print "/n/n/nUpdate scm/manifest after ref.binary update" @@ -342,7 +342,7 @@ def _update_scm_manifest(ref_list,base_prj_list,commit_msg): return 1 mygit = Git(prjdir) - git_branch = base_prj['git_branch'] + git_branch = base_prj['git_branch']+is_staging print 'git_prj: %s git_branch: %s' %(git_prj, git_branch) mygit.checkout(git_branch) @@ -378,8 +378,9 @@ def _update_scm_manifest(ref_list,base_prj_list,commit_msg): f.write(res2.read()) #metadata.xml + revision_branch='tizen'+is_staging metadata_file = profile_path + '/' + repository + '/metadata.xml' - metadata_text = '\n\n \n \n \n\n \n \n \n \n' print 'repository: %s' %repository print 'metadata_text: \n%s' %metadata_text @@ -413,24 +414,33 @@ def main(): print '---[JOB STARTED]----------------------------------------' - #comment out because this job is triggered by gbs-ref-fullbuild -# event = get_gerrit_event() - event = trigger_info(os.getenv("TRIGGER_INFO")) + #comment out because this job is triggered by gerrit event + event = get_gerrit_event() +# event = trigger_info(os.getenv("TRIGGER_INFO")) # prepare separate temp directory for each build - 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 - # react on and it's configured in the job configuraion - print >> sys.stderr, "Configuration error: This job can't process"\ - "project %s! Only scm/git-ref-mapping is allowed and " \ - "event %s! Only ref-updated events are allowed" \ - %(event['event_type'], event['project']) - return 1 - + # In case of this job is triggered by gerrit event, first submit meta files to staging branch + # 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' + 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 + # react on and it's configured in the job configuraion + print >> sys.stderr, "Configuration error: This job can't process"\ + "project %s! Only scm/git-ref-mapping is allowed and " \ + "event %s! Only ref-updated events are allowed" \ + %(event['event_type'], event['project']) + return 1 + else: + print 'update-gbs-meta job is triggered by gbs-ref-fullbuild' + event = trigger_info(os.getenv("TRIGGER_INFO")) + is_staging = '' + print 'is_staging is %s' %is_staging git_prj = event['project'] - git_branch = event['refname'] + git_branch = event['refname'] filename = 'git-ref-mapping.xml' tmpdir = tempfile.mkdtemp(prefix=workspace+'/') atexit.register(shutil.rmtree, tmpdir) @@ -461,9 +471,12 @@ def main(): ref_list = _update_ref_bin_index(ref_binary) base_prj_list = _update_base_prj_index() - _update_build_conf(ref_list,commit_msg) - _update_gbs_conf(ref_list,base_prj_list,commit_msg) - _update_scm_manifest(ref_list,base_prj_list,commit_msg) + _update_build_conf(ref_list,commit_msg,is_staging) + _update_gbs_conf(ref_list,base_prj_list,commit_msg,is_staging) + _update_scm_manifest(ref_list,base_prj_list,commit_msg,is_staging) + + if is_staging == '_staging': + trigger_next("gbs-reference-fullbuild",event) if __name__ == '__main__': sys.exit(main()) -- 2.7.4