From: hyokeun Date: Wed, 26 Apr 2017 02:31:30 +0000 (+0900) Subject: Set proper package name in requests job X-Git-Tag: submit/trunk/20190927.012743~473 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=15b5af0733aefdf00275e93065e31ec1d6a5b335;p=services%2Fjenkins-scripts.git Set proper package name in requests job Change-Id: I8dfa13c96876f3f271a55f34705199e06e80171f --- diff --git a/job_request.py b/job_request.py index f7fceb8..dccba56 100755 --- a/job_request.py +++ b/job_request.py @@ -26,6 +26,7 @@ from common.buildtrigger import trigger_info, trigger_next from common.send_mail import prepare_mail from common.buildservice import BuildService from common.iris_rest_client import IrisRestClient +from common.utils import unicode_to_str from obs_requests.mailer import mailer from gbp.git.repository import GitRepositoryError from gitbuildsys.errors import ObsError @@ -128,11 +129,20 @@ def obs_git_data(event_fields): projects = entry['GIT_PROJECTS'][1:-1].split(', ') else: projects.append(entry['GIT_PROJECTS']) + for project in projects: + # Get package name from OBS description. + # Assume items(packages, projects) are stored one after another. + obs_req_pkg_name = os.path.basename(project) + if len(projects) == len(event_fields['packages']): + try: + obs_req_pkg_name = event_fields['packages'][projects.index(project)] + except Exception as err: + print 'Warning: not able to find package name from description' tag = tag_info(project, entry['GIT_TAG']) tag.update({'GIT_PROJECT': project, - 'OBS_REQ_PKG_SRC': os.path.basename(project), - 'OBS_REQ_PKG': os.path.basename(project),}) + 'OBS_REQ_PKG_SRC': obs_req_pkg_name, + 'OBS_REQ_PKG': obs_req_pkg_name,}) projects_list.append(tag) else: print '-------------------------------------' @@ -167,16 +177,24 @@ def delete_from_obs(prj, pkg): os.getenv('OBS_API_USERNAME'), os.getenv('OBS_API_PASSWD')) + try: + if 'home:prerelease:' in prj: + print 'Removing %s' % prj + _bs.delete_project(prj) + except ObsError, error: + print error + if 'HTTP Error 404' in str(error): + return True + else: + return False + if not _bs.exists(prj, pkg): print '[Warning]:buildservice cannot find prj %s: pkg %s' % (prj, pkg) return True if _bs.get_package_real_project_name(prj, pkg) == prj: try: - if 'home:prerelease:' in prj: - print 'Removing %s' % prj - _bs.delete_project(prj) - else: + if True: print 'Removing %s:%s' % (prj, pkg) _bs.delete_package(prj, pkg) except ObsError, error: @@ -353,6 +371,17 @@ def main(): print 'Use number(%s) field instead of id' % event_fields.get('number') event_fields['id'] = event_fields.get('number') reqinfo = build.get_sr_info(event_fields.get('id')) + if 'targetproject' not in event_fields and 'targetproject' in reqinfo: + event_fields['targetproject'] = reqinfo['targetproject'] + if 'sourceproject' not in event_fields and 'sourceproject' in reqinfo: + event_fields['sourceproject'] = reqinfo['sourceproject'] + + try: + event_fields['packages'] = \ + unicode_to_str(build.get_info(event_fields['sourceproject'])['packages']) + except Exception as err: + print 'Not able to fetch package list from OBS %s' % err + event_fields['packages'] = [] for var in ['targetproject', 'sourceproject', 'comment', 'sender']: