当前位置: 首页>>代码示例>>Python>>正文


Python JIRA.assign_issue方法代码示例

本文整理汇总了Python中jira.JIRA.assign_issue方法的典型用法代码示例。如果您正苦于以下问题:Python JIRA.assign_issue方法的具体用法?Python JIRA.assign_issue怎么用?Python JIRA.assign_issue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jira.JIRA的用法示例。


在下文中一共展示了JIRA.assign_issue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: JIRA_PROJECT

# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import assign_issue [as 别名]
class JIRA_PROJECT(object):
    def __init__(self, server, project, basic_auth=()):
        self.server = server
        self.project = project
        self.basic_auth = basic_auth
        self._connect_to_jira()
    
    def _connect_to_jira(self):
        try:
            print 'Tyring to connect JIRA server: {} and project: {}...'.format(self.server, self.project)
            self.jira = JIRA(server=self.server, basic_auth=self.basic_auth)
            print 'JIRA server connected successfully...'
        except Exception as err:
            print 'JIRA Connection error'
            print err
            sys.exit(1)
                
    def get_defect_from_qc(self, qc_num):
        # print getattr(issue.fields, 'summary')
        # print getattr(issue.fields, '')
        if self.project is not 'TDETS':
            print 'Project is not TDETS'
            sys.exit(0)
        
        defects = self.jira.search_issues('project={}'.format(self.project), maxResults=5000)
        
        for defect in defects:
            print 'checking',  defect.key
            #defect = self.jira.issue(defect, fields='assignee,summary,status,customfield_13625,comment')
            defect = self.jira.issue(defect.key, fields='customfield_13625,summary,status,assignee')
            if (defect.fields.customfield_13625) and (qc_num in defect.fields.customfield_13625):
                    print defect.key
                    print defect.fields.customfield_13625
                    print defect.fields.summary
                    print defect.fields.status
                    print defect.fields.assignee
                    return defect.key
        else:
            print 'no matching QC found in TDETS'
            return None

    def get_my_defects(self):
        # print getattr(issue.fields, 'summary')
        # print getattr(issue.fields, 'customfield_13625')
        defects = self.jira.search_issues('project={} and assignee = currentUser()'.format(self.project))
        list_defects = []
        for defect in defects:
            defect = self.jira.issue(defect.key, fields='assignee,summary,status,customfield_13625,comment')
            
            if defect.fields.comment.comments:
                last_comment = defect.fields.comment.comments[-1].raw['body']
            else:
                last_comment = 'No Comment Yet'

            qc_id = getattr('defect.fields', 'customfield_13625', 'NO QC ID')
            #qc_id=defect.fields.customfield_13625
            defect_summary = DEFECT_SUMMARY(id=defect.key, 
                                     qc_id=qc_id,
                                     summary=defect.fields.summary, 
                                     status=defect.fields.status, 
                                     assignee=defect.fields.assignee, 
                                     last_comment=last_comment,
                                     )
  

            list_defects.append(defect_summary) 
        return list_defects
            
    def get_all_issues(self):
        pass
    
    def create_new_issue(self):
        pass
    
    def update_defect(self, defect, new_comment=None, new_assignee=None):
        #https://answers.atlassian.com/questions/8627641/update-custom-field-using-jira-python
        if new_comment:  
            #how to check new comment is posted correctly
            comment = self.jira.add_comment(defect, new_comment)
            if isinstance(comment, jira.resources.Comment):
                print 'Posted Comment:'
                print comment.raw['body']
            else:
                print 'Failed'
                return False
            
        if new_assignee:
            #update new assignee
            if not self.jira.assign_issue(defect, new_assignee):
                return False
        
        return True
    
    
    def get_defect_history(self, defect):
        # https://answers.atlassian.com/questions/64708/is-it-possible-to-get-the-issue-history-using-the-rest-api
        defect = self.jira.issue(defect, expand='changelog')
         
        for history in defect.changelog.histories:
            for item in history.items:
#.........这里部分代码省略.........
开发者ID:twogreenfrogs,项目名称:python_scripts,代码行数:103,代码来源:cts_jira_examples.py

示例2: update_tickets_from_git

# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import assign_issue [as 别名]

#.........这里部分代码省略.........
        self.vprint('-'*80)
        self.vprint('current.keys:', current.keys())

#         try:
#             last_commit = last['GITTRACKER']['current_commit']
#         except KeyError:
#             return
#         current_commit = current['GITTRACKER']['current_commit']

        # Find all tickets deployed between last deployment and now.
        tickets = self.get_tickets_between_commits(current_commit, last_commit)
        self.vprint('tickets:', tickets)

        # Update all tickets in Jira.
        jira = JIRA({
            'server': self.env.server
        }, basic_auth=(self.env.basic_auth_username, self.env.basic_auth_password))
        for ticket in tickets:

            # Mention this Jira updated.
            r.env.role = r.genv.ROLE.lower()
            comment = r.format(self.env.ticket_update_message_template)
            print('Commenting on ticket %s: %s' % (ticket, comment))
            if not self.dryrun:
                jira.add_comment(ticket, comment)

            # Update ticket status.
            recheck = False
            while 1:
                print('Looking up jira ticket %s...' % ticket)
                issue = jira.issue(ticket)
                self.vprint('Ticket %s retrieved.' % ticket)
                transition_to_id = dict((t['name'], t['id']) for t in jira.transitions(issue))
                self.vprint('%i allowable transitions found:' % len(transition_to_id))
                if self.verbose:
                    pprint(transition_to_id)
                self.vprint('issue.fields.status.id:', issue.fields.status.id)
                self.vprint('issue.fields.status.name:', issue.fields.status.name)
                jira_status_id = issue.fields.status.name.title()
                self.vprint('jira_status_id:', jira_status_id)
                next_transition_name = self.env.deploy_workflow.get(jira_status_id)
                self.vprint('next_transition_name:', next_transition_name)
                next_transition_id = transition_to_id.get(next_transition_name)
                self.vprint('next_transition_id:', next_transition_id)
                if next_transition_name:
                    if issue.fields.assignee:
                        if issue.fields.assignee.raw:
                            assignee_name = issue.fields.assignee.name
                        else:
                            # Get assignee name directly
                            # https://community.atlassian.com/t5/Jira-questions/Jira-in-Python-issue-fields-reporter-name-
                            # errors-with-TypeError/qaq-p/937924
                            assignee_name = issue.fields.assignee._session['name']
                    else:
                        assignee_name = None

                    # Get new assignee by status
                    new_assignee = self.env.assignee_by_status.get(
                        #issue.fields.status.name.title(),
                        next_transition_name,
                        assignee_name,
                    )

                    # If assigning to reporter, get reporter name.
                    if new_assignee == 'reporter':
                        if issue.fields.reporter.raw:
                            new_assignee = issue.fields.reporter.name
                        else:
                            # Get reporter name directly
                            # https://community.atlassian.com/t5/Jira-questions/Jira-in-Python-issue-fields-reporter-name-
                            # errors-with-TypeError/qaq-p/937924
                            new_assignee = issue.fields.reporter._session['name']

                    print('Updating ticket %s to status %s (%s) and assigning it to %s.' % (ticket, next_transition_name, next_transition_id, new_assignee))
                    if not self.dryrun:

                        if next_transition_id:
                            try:
                                jira.transition_issue(issue, next_transition_id)
                                recheck = True
                            except AttributeError as e:
                                print('Unable to transition ticket %s to %s: %s' % (ticket, next_transition_name, e), file=sys.stderr)
                                traceback.print_exc()

                        # Note assignment should happen after transition, since the assignment may
                        # effect remove transitions that we need.
                        try:
                            if new_assignee:
                                print('Assigning ticket %s to %s.' % (ticket, new_assignee))
                                jira.assign_issue(issue, new_assignee)
                            else:
                                print('No new assignee found.')
                        except JIRAError as e:
                            print('Unable to reassign ticket %s to %s: %s' % (ticket, new_assignee, e), file=sys.stderr)
                else:
                    recheck = False
                    print('No transitions found for ticket %s currently in status "%s".' % (ticket, issue.fields.status.name))

                if not recheck:
                    break
开发者ID:chrisspen,项目名称:burlap,代码行数:104,代码来源:jirahelper.py

示例3: prettyXML

# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import assign_issue [as 别名]
			failureDetails = failureDetails + '{code:title=' + testurl + '' + className_re + '/' + name_re + '}\n'
			failureDetails = failureDetails + prettyXML(s)
			failureDetails = failureDetails + '\n{code}\n\n'
			#print failureDetails

		rootJBIDE_dict = {
			'project' : { 'key': 'JBIDE' },
			'summary' : str(len(testcaselist)) + ' Test Failure(s) in JBIDE ' + jbide_affectedversion + ' for ' + component + ' component',
			'description' :  failureSummary + failureDetails,
			'issuetype' : { 'name' : 'Task' },
			'priority' : { 'name' :'Critical'},
			'versions' : [{ "name" : jbide_affectedversion }],
			'components' : [{ "name" : component }],
			'labels' : [ "testfailure" ]
			}

		jira = JIRA(options={'server':jiraserver}, basic_auth=(options.usernameJIRA, options.passwordJIRA))
		CLJBIDE = jira.project_components(jira.project('JBIDE')) # full list of components in JBIDE
		rootJBIDE = jira.create_issue(fields=rootJBIDE_dict)
		componentLead = queryComponentLead(CLJBIDE, component, 0)
		try:
			jira.assign_issue(rootJBIDE, componentLead)
		except:
			print "[WARNING] Unexpected error! User {0} tried to assign {1} to {2}: {3}".format(options.usernameJIRA, rootJBIDE, componentLead, sys.exc_info()[0])
		accept = raw_input("\nAccept new JIRA " + jiraserver + '/browse/' + rootJBIDE.key + " => " + componentLead + " ? [Y/n] ")
		if accept.capitalize() in ["N"] :
			rootJBIDE.delete()

	# see JIRA_components listing in components.py

	# Sample usage: see createTestFailureJIRA.py.examples.txt
开发者ID:nickboldt,项目名称:jbosstools-build-ci,代码行数:33,代码来源:createTestFailureJIRA.py

示例4: queryComponentLead

# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import assign_issue [as 别名]
	if not options.componentjbide and not options.componentjbds:
		rootJBDS_dict = {
			'project' : { 'key': 'JBDS' },
			'summary' : 'For JBDS ' + jbds_fixversion + ': ' + taskdescription,
			'description' : 'For JBDS ' + jbds_fixversion + ': ' + taskdescriptionfull + '\n\n[Search for all task JIRA|' + tasksearch + ']',
			'issuetype' : { 'name' : 'Task' },
			'priority' : { 'name' :'Blocker'},
			'fixVersions' : [{ "name" : jbds_fixversion }],
			'components' : [{ "name" : "installer" }],
			'labels' : [ "task" ],
			}
		rootJBDS = jira.create_issue(fields=rootJBDS_dict)
		installerLead = queryComponentLead(CLJBDS, 'installer', 0)
		try:
			jira.assign_issue(rootJBDS, installerLead)
		except:
			if (not options.jiraonly):
				print "[WARNING] Unexpected error! User {0} tried to assign {1} to {2}: {3}".format(options.usernameJIRA, rootJBDS, installerLead, sys.exc_info()[0])
		if (options.jiraonly):
			print(rootJBDS.key)
		else:
			print("Task JIRA created for this milestone include:")
			print("")
			print("JBDS              : " + jiraserver + '/browse/' + rootJBDS.key + " => " + installerLead)

		rootJBIDE_dict = {
			'project' : { 'key': 'JBIDE' },
			'summary' : 'For JBIDE ' + jbide_fixversion + ': ' + taskdescription,
			'description' : 'For JBIDE ' + jbide_fixversion + ': ' + taskdescriptionfull + 
				'\n\n[Search for all task JIRA|' + tasksearch + ']\n\nSee also: ' + rootJBDS.key,
开发者ID:nickboldt,项目名称:jbosstools-build-ci,代码行数:32,代码来源:createTaskJIRAs.py

示例5: AND

# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import assign_issue [as 别名]
	nnissuesquerythisversion = 'summary ~ "New and Noteworthy" AND ((project in (JBDS) and fixVersion = "' + jbds_fixversion + '") or (project in (JBIDE) and fixVersion = "' + jbide_fixversion + '")) ORDER BY key DESC'

	rootnn_description = 'This [query|' + nnsearch + '] contains the search for all N&N. See subtasks below.'
	rootnn_dict = {
		'project' : { 'key' : 'JBIDE' },
		'summary' : 'Create New and Noteworthy for ' + jbide_fixversion,
		'description' : rootnn_description,
		'issuetype' : { 'name' : 'Task' },
		'priority' : { 'name' :'Blocker'},
		'fixVersions' : [{ "name" : jbide_fixversion }],
		'components' : [{ "name" : "website" }]
		}
	rootnn = jira.create_issue(fields=rootnn_dict)
	componentLead = defaultAssignee()
	try:
		jira.assign_issue(rootnn, componentLead)
	except:
		print "[WARNING] Unexpected error! User {0} tried to assign {1} to {2}: {3}".format(options.usernameJIRA, rootnn, componentLead, sys.exc_info()[0])

	print("JBoss Tools       : " + jiraserver + '/browse/' + rootnn.key + " => " + componentLead + "")

	def nametuple(x):
		return { "name" : x }

	def quote(x):
		return '"' + x + '"'

	# see JIRA_components listing in components.py
	from components import NN_components

	for name, comps in NN_components.iteritems():
开发者ID:nickboldt,项目名称:jbosstools-build-ci,代码行数:33,代码来源:createnewandnoteworthy.py

示例6: Category

# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import assign_issue [as 别名]
            'customfield_17680' : { 'value' : 'Low' }, # complexity of change
            'customfield_17681' : { 'value' : 'Low' }, # Pre-Testing
            'customfield_17682' : { 'value' : 'Low' }, # Scope of Validation
            'customfield_17683' : { 'value' : 'Low' }, # Rollback Plan
            'customfield_17684' : { 'value' : 'Low' }, # Customer landscape impact
            'customfield_16583' : {'value':'App', 'child': {'value':'Update/Upgrade'}}, # Category(s) 
            'components' : [{'name': 'JAM'}], #Components
            'customfield_15282' : {'value':'No Data Protection Regulation'}, # Customer Data Protection
            'customfield_10802' : { 'value' : dc_total }, # Data Center
            'customfield_16590' : { 'id' : time_Zone },# DC Time Zone
            'customfield_10842' : { 'id' : env_type }, # Environment Type 
            'customfield_16794' : {'value':'None'}, # Customer Impact
            'customfield_17055' : {'value':'No'}, # CCM Notify
            'customfield_17056' : { 'value' : 'Not Required' }, # Maintenance Page Required?
            'customfield_17057' : { 'value' : 'No' }, # Pop up enable required?
            'customfield_16814' : actual_date+ 'T11:30:00.000-0700', # requested Start 
            'customfield_16815' : actual_date+ 'T11:30:00.000-0700', # requested End 
            'description' : descript, # description
            'customfield_17426' : test_details, # Pre-Test Details
            'customfield_17427' : justification, # Business Justification
            'customfield_17058' : imp_steps, # Implementation Steps
            'customfield_16800' : back_steps, # Backout Steps
            'customfield_16801' : validate, # Validation Steps
            'customfield_16802' : { 'name' : 'svishwanath' }, # Validator
            'customfield_17059' : [{ 'value' : 'TechOwn - JAM' }],  #Tech Approver 17059
            'customfield_17060' : [{ 'value' : 'BusOwn - JAM' }], # Impact/Impl Approver 17060
                    }
        new_issue = jira.create_issue(fields=values)
        jira.assign_issue(new_issue, 'sureshkumara')
        print new_issue.key
开发者ID:sv456,项目名称:Python,代码行数:32,代码来源:JAM_ticket_Auto_Creation.py

示例7: update_tickets_from_git

# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import assign_issue [as 别名]

#.........这里部分代码省略.........
        return
    
    if not env.jira_update_from_git:
        return
    
    if not env.jira_ticket_pattern:
        return
    
    if not env.jira_basic_auth_username or not env.jira_basic_auth_password:
        return
    
    # During a deployment, we should be given these, but for testing,
    # lookup the diffs dynamically.
    if not last or not current:
        last, current = get_last_current_diffs(GITTRACKER)
    
    if verbose:
        print('-'*80)
        print('last.keys:', last.keys())
        print('-'*80)
        print('current.keys:', current.keys())
    
    try:
        last_commit = last['GITTRACKER']['current_commit']
    except KeyError:
        return
    current_commit = current['GITTRACKER']['current_commit']
    
    # Find all tickets deployed between last deployment and now.
    tickets = get_tickets_between_commits(current_commit, last_commit)
    if verbose:
        print('tickets:', tickets)
    
    # Update all tickets in Jira.
    jira = JIRA({
        'server': env.jira_server
    }, basic_auth=(env.jira_basic_auth_username, env.jira_basic_auth_password))
    for ticket in tickets:
        
        # Mention this Jira updated.
        comment = env.jira_ticket_update_message_template % dict(role=env.ROLE.lower())
        print('Commenting on ticket %s: %s' % (ticket, comment))
        if not dryrun:
            jira.add_comment(ticket, comment) 
        
        # Update ticket status.
        recheck = False
        while 1:
            print('Looking up jira ticket %s...' % ticket)
            issue = jira.issue(ticket)
            print('Ticket %s retrieved.' % ticket)
            transition_to_id = dict((t['name'], t['id']) for t in jira.transitions(issue))
            print('%i allowable transitions found: %s' % (len(transition_to_id), ', '.join(transition_to_id.keys())))
            next_transition_name = env.jira_deploy_workflow.get(issue.fields.status.name.title())
            next_transition_id = transition_to_id.get(next_transition_name)
            if next_transition_name:
                new_fields = {}
                
#                 print('jira_assignee_by_status:', env.jira_assignee_by_status, issue.fields.status.name.title()
                new_assignee = env.jira_assignee_by_status.get(
                    #issue.fields.status.name.title(),
                    next_transition_name,
                    issue.fields.assignee.name,
                )
                if new_assignee == 'reporter':
                    new_assignee = issue.fields.reporter.name
#                 print('new_assignee:', new_assignee)
                    
                print('Updating ticket %s to status %s and assigning it to %s.' \
                    % (ticket, next_transition_name, new_assignee))
                if not dryrun:
                    try:
                        jira.transition_issue(
                            issue,
                            next_transition_id,
                        )
                        recheck = True
                    except AttributeError as e:
                        print('Unable to transition ticket %s to %s: %s' \
                            % (ticket, next_transition_name, e), file=sys.stderr)
                    
                    # Note assignment should happen after transition, since the assignment may
                    # effect remove transitions that we need.
                    try:
                        if new_assignee:
                            print('Assigning ticket %s to %s.' % (ticket, new_assignee))
                            jira.assign_issue(issue, new_assignee)
                        else:
                            print('No new assignee found.')
                    except JIRAError as e:
                        print('Unable to reassign ticket %s to %s: %s' \
                            % (ticket, new_assignee, e), file=sys.stderr)
            else:
                recheck = False
                print('No transitions found for ticket %s currently in status "%s".' \
                    % (ticket, issue.fields.status.name))
                    
            if not recheck:
                break
                
开发者ID:noeldvictor,项目名称:burlap,代码行数:103,代码来源:jirahelp.py


注:本文中的jira.JIRA.assign_issue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。