def setup_profile(project):
""" Setup profile """
+ profile_list = []
+
if os.getenv('RBS_PROFILES'):
profiles = ast.literal_eval(os.getenv('RBS_PROFILES'))
else:
if project == l['project']:
profile = l
print 'project = %s' % (project)
- return profile
+ #return profile
+ profile_list.append(profile)
- return False
+ return profile_list
def send_mail(title, msg, receiver):
""" post message back to gerrit and send mail to tag owner """
print 'Error: TRIGGER_INFO doesn\'t contain %s' % field
return -1
- profile = setup_profile(fields['project'])
- if not profile:
- print 'Skip TRIGGER job for the project %s' % fields['project']
- return 0
-
- vm_image = os.getenv("RBS_VM_IMAGE")
-
- if not vm_image:
- print 'VM not vm_image'
- return -1
+ profile_list = setup_profile(fields['project'])
- if not os.access(vm_image, os.R_OK):
- print 'VM not access'
- return -1
+ for profile in profile_list:
+ if not profile:
+ print 'Skip TRIGGER job for the project %s' % fields['project']
+ return 0
- # check if tarball exists
- if not vm_image or not os.access(vm_image, os.R_OK):
- print 'VM image %s is not found' % vm_image
- return -1
+ vm_image = os.getenv("RBS_VM_IMAGE")
- # clone git sdk-image
- git_prj = profile['git_rs_prj']
+ if not vm_image:
+ print 'VM not vm_image'
+ return -1
- git_cache = os.getenv("GIT_CACHE_DIR")
- print 'Cloning %s' % git_prj
- if not clone_gitproject(git_prj, \
- os.path.join(git_cache, git_prj)):
- raise LocalError('Error cloning %s' % git_prj)
+ if not os.access(vm_image, os.R_OK):
+ print 'VM not access'
+ return -1
- mygit = Git(os.path.join(git_cache, git_prj))
+ # check if tarball exists
+ if not vm_image or not os.access(vm_image, os.R_OK):
+ print 'VM image %s is not found' % vm_image
+ return -1
- status = 'succeeded'
- reason = 'ok'
- #### Make Rootstrap Snapshot (PRIVATE)####
- status = make_rs_snapshot_private(git_prj, git_cache, mygit, fields, profile, vm_image)
+ # clone git sdk-image
+ git_prj = profile['git_rs_prj']
- if status == 'succeeded':
- print "The RBS(Internal) build was successful."
- else:
- print "The RBS(Internal) build was failed."
- reason = 'RBS build fail'
+ git_cache = os.getenv("GIT_CACHE_DIR")
+ print 'Cloning %s' % git_prj
+ if not clone_gitproject(git_prj, \
+ os.path.join(git_cache, git_prj)):
+ raise LocalError('Error cloning %s' % git_prj)
- try:
- update_dashboard(fields['project'], \
- fields['build_id'].split('_')[-1],
- status, reason,
- fields.get('infra', 'LOCAL')
- )
- except Exception as err:
- print repr(err)
+ mygit = Git(os.path.join(git_cache, git_prj))
- status = 'succeeded'
- #### Make Rootstrap Snapshot (PUBLIC)####
- status = make_rs_snapshot_public(git_prj, git_cache, mygit, fields, profile, vm_image)
+ status = 'succeeded'
+ reason = 'ok'
+ #### Make Rootstrap Snapshot (PRIVATE)####
+ status = make_rs_snapshot_private(git_prj, git_cache, mygit, fields, profile, vm_image)
- #### Misc public rootstraps ####
- if profile.get('misc_branches'):
- for mb in profile.get('misc_branches'):
- status_1 = make_rs_snapshot_public(git_prj, git_cache, mygit, fields, profile, vm_image, specific_branch=mb)
- if status_1 != 'succeeded':
- status = status_1
+ if status == 'succeeded':
+ print "The RBS(Internal) build was successful."
+ else:
+ print "The RBS(Internal) build was failed."
+ reason = 'RBS build fail'
- if status == 'succeeded':
- print "The RBS(Public) build was successful."
- else:
- print "The RBS(Public) build was failed."
+ try:
+ update_dashboard(fields['project'], \
+ fields['build_id'].split('_')[-1],
+ status, reason,
+ fields.get('infra', 'LOCAL')
+ )
+ except Exception as err:
+ print repr(err)
+
+ status = 'succeeded'
+ #### Make Rootstrap Snapshot (PUBLIC)####
+ status = make_rs_snapshot_public(git_prj, git_cache, mygit, fields, profile, vm_image)
+
+ #### Misc public rootstraps ####
+ if profile.get('misc_branches'):
+ for mb in profile.get('misc_branches'):
+ status_1 = make_rs_snapshot_public(git_prj, git_cache, mygit, fields, profile, vm_image, specific_branch=mb)
+ if status_1 != 'succeeded':
+ status = status_1
+
+ if status == 'succeeded':
+ print "The RBS(Public) build was successful."
+ else:
+ print "The RBS(Public) build was failed."
return 0