Esempio n. 1
0
    def remote(self, server='localhost:8000'):
        ''' 
        Establishes identities for GUS and Code collab for proxy ticket update
        and code review creation.  Code collab client cannot activate review for
        remote.
        '''
        gus = BacklogClient()
        session_id = gus.session_id()
        cc = CodeCollabClient()
        author = cc.get_current_user()
        mrhat = MrHat()
        creds = mrhat.get_current_creds()
        commit = self.buildCommit()
        commit['gus_session'] = session_id
        commit['collab_user'] = author
        commit['jenkins_user'] = creds[0]
        commit['jenkins_token'] = creds[1]

        conn = httplib.HTTPConnection(server)
        head = {
            'Content-Type': 'application/json',
            'Accept': 'application/json'
        }
        conn.request('POST', '/service/post', json.dumps(commit), head)
        response = conn.getresponse()
        data = response.read()
        conn.close()

        print data
Esempio n. 2
0
 def remote(self, server='localhost:8000'):
     ''' 
     Establishes identities for GUS and Code collab for proxy ticket update
     and code review creation.  Code collab client cannot activate review for
     remote.
     '''
     gus = BacklogClient()
     session_id = gus.session_id()
     cc = CodeCollabClient()
     author = cc.get_current_user()
     mrhat = MrHat()
     creds = mrhat.get_current_creds()
     commit = self.buildCommit()
     commit['gus_session'] = session_id
     commit['collab_user'] = author
     commit['jenkins_user'] = creds[0]
     commit['jenkins_token'] = creds[1]
     
     conn = httplib.HTTPConnection(server)
     head = {
         'Content-Type' : 'application/json',
         'Accept'       : 'application/json'
     }
     conn.request('POST','/service/post', json.dumps(commit), head)
     response = conn.getresponse()
     data = response.read()
     conn.close()
     
     print data
Esempio n. 3
0
 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'
Esempio n. 4
0
    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'
Esempio n. 5
0
 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