def gus(self, commit): ''' Updates the gus item to fixed as long as there is a 'fixes' and 'scheduled_build' annotation in the commit message ''' if self.__is_valid_fix__(commit): if 'next' in commit['annotations']: mrhat = MrHat() scheduled_build = mrhat.find_next_build(commit['annotations']['next']) else: scheduled_build = commit['annotations']['scheduled_build'] work_name = commit['annotations']['fixes'] try: gus = self.__gus_session__(commit) buildid = gus.find_build_id(scheduled_build) work = gus.find_work(work_name) gus.mark_work_fixed(work["Id"], buildid) gus.add_changelist_comment(work["Id"], "%s\n\n%s" % (commit['title'], commit['overview']), commit['changelist']) print 'Updated Work Item %s (%s) status to Fixed in build %s' % (work_name, work['Id'], scheduled_build) except Exception as e: print 'Unable to update Gus: %s' % str(e) elif 'updates' in commit['annotations']: work_name = commit['annotations']['updates'] try: gus = self.__gus_session__(commit) work = gus.find_work(work_name) gus.mark_work_in_progress(work["Id"]) gus.add_changelist_comment(work["Id"], "%s\n\n%s" % (commit['title'], commit['overview']), commit['changelist']) print 'Updated Work Item %s (%s) status to In Progress' % (work_name, work['Id']) except Exception as e: print 'Unable to update Gus: %s' % str(e) else: print 'No Gus annotations (fixes with scheduled_build or next, updates), not updating Gus'
def gus(self, commit): ''' Updates the gus item to fixed as long as there is a 'fixes' and 'scheduled_build' annotation in the commit message ''' if self.__is_valid_fix__(commit): if 'next' in commit['annotations']: mrhat = MrHat() scheduled_build = mrhat.find_next_build( commit['annotations']['next']) else: scheduled_build = commit['annotations']['scheduled_build'] work_name = commit['annotations']['fixes'] try: gus = self.__gus_session__(commit) buildid = gus.find_build_id(scheduled_build) work = gus.find_work(work_name) gus.mark_work_fixed(work["Id"], buildid) gus.add_changelist_comment( work["Id"], "%s\n\n%s" % (commit['title'], commit['overview']), commit['changelist']) print 'Updated Work Item %s (%s) status to Fixed in build %s' % ( work_name, work['Id'], scheduled_build) except Exception as e: print 'Unable to update Gus: %s' % str(e) elif 'updates' in commit['annotations']: work_name = commit['annotations']['updates'] try: gus = self.__gus_session__(commit) work = gus.find_work(work_name) gus.mark_work_in_progress(work["Id"]) gus.add_changelist_comment( work["Id"], "%s\n\n%s" % (commit['title'], commit['overview']), commit['changelist']) print 'Updated Work Item %s (%s) status to In Progress' % ( work_name, work['Id']) except Exception as e: print 'Unable to update Gus: %s' % str(e) else: print 'No Gus annotations (fixes with scheduled_build or next, updates), not updating Gus'
def validate(self, comment): messages = [] annotations = comment.annotations() build_id = None if 'scheduled_build' in annotations: build_id = annotations['scheduled_build'] elif 'next' in annotations: mrhat = MrHat() build_id = mrhat.find_next_build(annotations['next']) if build_id is not None: try: gus = BacklogClient() gus.find_build_id(build_id) except NoRecordException: messages.append("Build label %s is not valid. Please specify a valid build label with either @scheduled_build or @next." % build_id) except: messages.append("Unable to connect to Gus to validate build. Connect to vpn before committing") return messages