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')
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'
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":
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
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:
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')
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"
# 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)
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"
# 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)
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"
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)
f.write(res2.read())
#metadata.xml
+ revision_branch='tizen'+is_staging
metadata_file = profile_path + '/' + repository + '/metadata.xml'
- metadata_text = '<?xml version="1.0" encoding="UTF-8"?>\n<manifest>\n <project name="scm/meta/build-config" path="scm/meta/build-config" groups="meta" revision="tizen"/>\n <project name="scm/meta/gbs-config" path="scm/meta/gbs-config" groups="meta" revision="tizen">\n <copyfile src="'
+ metadata_text = '<?xml version="1.0" encoding="UTF-8"?>\n<manifest>\n <project name="scm/meta/build-config" path="scm/meta/build-config" groups="meta" revision="'+revision_branch+'"/>\n <project name="scm/meta/gbs-config" path="scm/meta/gbs-config" groups="meta" revision="'+revision_branch+'">\n <copyfile src="'
metadata_text += t_ver.replace('-','/')+profile+'/'+repository+'_gbs.conf" dest=".gbs.conf" />\n </project>\n</manifest>'
print 'repository: %s' %repository
print 'metadata_text: \n%s' %metadata_text
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)
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())