本文整理汇总了Python中jira.JIRA.search_issues方法的典型用法代码示例。如果您正苦于以下问题:Python JIRA.search_issues方法的具体用法?Python JIRA.search_issues怎么用?Python JIRA.search_issues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jira.JIRA
的用法示例。
在下文中一共展示了JIRA.search_issues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: JiraIntegration
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import search_issues [as 别名]
class JiraIntegration(object):
def signIn(self, jiraurl, username, password):
try:
self.__authed_jira = JIRA(server=jiraurl,
basic_auth=(username, password),
logging=True,
max_retries=3)
return True
except Exception:
return False
def signOut(self):
try:
self.__authed_jira.kill_session()
return True
except Exception:
return False
def getOpenIssues(self):
issues = self.__authed_jira.search_issues("""assignee = currentUser()
and sprint in openSprints ()
order by priority desc""", maxResults=5)
return issues
def getTitlesForMany(self, issue_id_list):
issues = self.__authed_jira.search_issues(' key in (%s)' % issue_id_list.join(','))
return issues
def getTitleFor(self, issue_id):
issues = self.__authed_jira.search_issues(' key in (%s)' % issue_id)
return issues
示例2: main
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import search_issues [as 别名]
def main(repo, project):
jira = JIRA(JIRA_URL, basic_auth=[JIRA_USERNAME, JIRA_PASSWORD])
print("Connection to JIRA successfully established.")
print("Fetching list of matching issues...")
# Get issue list for all the issues that match given project
issue_list = []
for year in range(JIRA_YEAR_START, JIRA_YEAR_END + 1):
jira_filter = JIRA_FILTER_TEMP.format(project=project, start=year, end=year+1)
issue_list += jira.search_issues(jira_filter, maxResults=5000)
# Sort issue list
sorted_issue_list = list(sorted(
issue_list,
key=lambda i: int(i.key.split('-')[1])
))
print(f"Fetching milestones...")
milestone_map = generate_milestone_map(repo, sorted_issue_list)
print(f"The script will process {len(sorted_issue_list)} matching issues now.")
issue = jira.issue(sorted_issue_list[0].key)
for issue_key in [i.key for i in sorted_issue_list]:
issue = jira.issue(issue_key)
data, comments = generate_issue_data(issue, milestone_map)
comments.insert(0, generate_meta_comment(issue))
download_attachments(issue)
create_issue(repo, data, comments)
time.sleep(REQUEST_SLEEP)
示例3: show
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import search_issues [as 别名]
def show(self, message, bug):
"""show lp ____: Show details of bug ___ on Launchpad"""
launchpad = Launchpad.login_anonymously('just testing', 'production')
self.say(
self.render_lp(launchpad.bugs[bug]),
message=message,
html=True
)
jira = JIRA(
basic_auth=(settings.JIRA_USER, settings.JIRA_PASS),
server=settings.JIRA_HOST,
validate=False,
options={'verify': False}
)
issues = jira.search_issues(self.SEARCH_PATTERN % (
settings.JIRA_PROJ, bug, bug))
if len(issues) > 0:
self.say("I also found a jira ticket for that", message=message)
for issue in issues:
self.say(
self.render_jira(issue),
message=message,
html=True
)
示例4: get_activity
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import search_issues [as 别名]
def get_activity(self, params):
"""
Takes time entries in format and reports them into destinatin set in
config. Entries are in following format:
>>> (Record(date=datatime, comment="activity comment", task="TaskID"),
... ...)
"""
jira = JIRA(
params['server'], basic_auth=(params['uname'], params['pswd']))
# check issues assigned on user and is in targeted statuses, or status was chened in given period
# TODO: dates seems to be random...
statuses = ("Code Review", "In Progress")
subquery_item = '(status CHANGED during ("{after}", "{before}") TO "{status}" and assignee = "{user}")'
subquery = " or ".join(subquery_item.format(status=s, **params) for s in statuses)
query = '''
project={project}
and (assignee = "{user}" and status in {statuses})
or {subquery}'''.format(subquery=subquery, statuses=statuses, **params)
issues = jira.search_issues(query, expand='changelog')
# import pdb; pdb.set_trace()
work_records = [
WorkRecord(
date=issue.fields.updated,
comment=issue.fields.summary,
task=issue.key,
type=issue.fields.status.name)
for issue in issues]
return work_records
示例5: retrieve_data_from_jira
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import search_issues [as 别名]
def retrieve_data_from_jira(ipds):
try:
sys.path.insert(0, CONFIGDIR) # add cwd to Python path in order to find config file
import jiraconfig # here, I was not able to use the CONFIGFILENAME variable
except ImportError:
print "\nERROR: Could not find \"" + CONFIGFILENAME + \
"\".\nPlease generate such a file in the " + \
"same directory as this script with following content and configure accordingly:\n" + \
CONFIGTEMPLATE
sys.exit(11)
try:
from jira import JIRA
except ImportError:
print_line("ERROR: Could not find Python module \"JIRA\".\nPlease install it, e.g., with \"sudo pip install jira\".")
sys.exit(12)
jira = JIRA('https://r6portal-defects.infonova.com/', basic_auth=(jiraconfig.JIRA_USER, jiraconfig.JIRA_PASSWORD))
query = 'key = "IPD-' + '" or key = "IPD-'.join(ipds) + '" ORDER BY key'
queryissues = jira.search_issues(query)
issues = []
for issue in queryissues:
if issue.fields.issuetype.name == u'Epic':
## if it is an Epic, query for its stories instead
epicquery = 'project = ipd and type = Story and "Epic Link" = ' + issue.key + ' ORDER BY key'
#print 'DEBUG: found epic, query=[' + epicquery + ']'
epicissues = jira.search_issues(epicquery)
issues.extend(retrieve_data_from_jira([x.key.replace('IPD-', '') for x in epicissues]))
elif issue.fields.issuetype.name == u'Story':
#print 'DEBUG: found story'
issues.append(extract_issue_fields(issue))
else:
## report Defects and so forth
print_line(u'ERROR: IPD-' + issue.key + ' is a ' + issue.fields.issuetype.name + \
'. Only Stories and Epics are handled here.')
sys.exit(13)
return issues
示例6: test_connection
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import search_issues [as 别名]
def test_connection(self):
from jira import JIRA
from burlap.common import print_success, print_fail
try:
print('Connecting to %s with user %s...' % (self.env.server, self.env.basic_auth_username))
jira = JIRA({
'server': self.env.server
}, basic_auth=(self.env.basic_auth_username, self.env.basic_auth_password))
result = jira.search_issues('status=resolved')
#print('result:', result)
print_success('OK')
except Exception as exc:
print_fail('ERROR: %s' % exc)
示例7: retrieve_counts
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import search_issues [as 别名]
def retrieve_counts():
jira = JIRA({"server": "https://issues.citrite.net"})
counts = {}
try:
for (name, jira_filter) in queries.iteritems():
jql = "filter='%s'" % jira_filter
response = jira.search_issues(jql, maxResults=1, fields='key',
json_result=True)
counts[name] = response['total']
except JIRAError as e:
sys.stderr.write("error: Could not retrieve_counts from JIRA: %s" % e)
exit(3)
return counts
示例8: JIRAOperator
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import search_issues [as 别名]
class JIRAOperator(object):
def __init__(self, server, username, password):
# Initial jira
# set verify as false to get rid of requests.exceptions.SSLError: [Errno 1] _ssl.c:507: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
options = {'server': server, 'verify': False}
self.__jira = JIRA(options, basic_auth=(username, password))
def search_issues(self, sql_str):
issues = self.__jira.search_issues(sql_str)
return issues
def search_open_bugs_by_priority(self, project, priority, end_status="done"):
JQL_str="project in ({0}) and issuetype = Bug and status not in ({1}) and priority = {2}".format(project, end_status, priority)
return self.search_issues(JQL_str)
示例9: main
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import search_issues [as 别名]
def main():
options = {
'server': config['JIRA']
}
jira = JIRA(options, basic_auth=(config['USERNAME'], config['PASSWORD']))
months = [
('2015-03', '2015-04'),
('2015-04', '2015-05'),
('2015-05', '2015-06'),
('2015-06', '2015-07'),
('2015-07', '2015-08'),
('2015-08', '2015-09'),
('2015-09', '2015-10'),
('2015-10', '2015-11'),
('2015-11', '2015-12'),
('2015-12', '2016-01'),
('2016-01', '2016-02'),
('2016-02', '2016-03'),
('2016-03', '2016-04')
]
total_issues = 0
bulk_add = []
for month in months:
print("Downloading issues for interval %s/%s" % month)
jql = "created >= '%s-01' AND created < '%s-01'" % month
issues_in_month = jira.search_issues(jql, maxResults=1000, json_result=True)
issues = issues_in_month['issues']
filtered_issues = filter_issues(issues)
issues_count = len(issues)
filtered_count = len(filtered_issues)
assert filtered_count == issues_count
total_issues = total_issues + issues_count
bulk_add.extend(filtered_issues)
print("Successfully downloaded %d issues" % total_issues)
print("Loading %d issues into RethinkDB" % len(bulk_add))
r.connect(config['RETHINKDB'], 28015, db='jira').repl()
r.table_drop('issues').run()
r.table_create('issues').run()
r.table('issues').insert(bulk_add).run()
print("OK! Bye")
示例10: retrun_jira_24hrs
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import search_issues [as 别名]
def retrun_jira_24hrs():
jira = JIRA({"server": "https://issues.couchbase.com"})
issues = jira.search_issues("created>-1d AND project=MB")
return_jira_list = []
for tix in issues:
#print tix
bug = jira.issue(tix.key) #get the actual jira ticket with details
#print bug.fields.summary
#print bug.fields.components
print type(bug.fields.components)
print type(bug.fields.components[0])
#print "Bug is is {0} - Component - {1} - Summary - {2}".format(tix,bug.fields.components, bug.fields.summary)
return_jira_list.append("Bug No - {0} - Component - {1} - Summary - {2}".format(tix,bug.fields.components, bug.fields.summary))
#return return_jira_list
return return_jira_list
示例11: search_jira_domains
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import search_issues [as 别名]
def search_jira_domains(domains, username, **kwargs):
search_field = ','.join(FIELDS)
search_str = "(assignee = {0} OR reporter = {0})" \
"AND (updated >= '{1}' OR created >= '{1}')" \
"AND (updated < '{2}' OR created < '{2}')" \
"ORDER BY updated {3}".format(username, kwargs.get('start_date', date(1990, 1, 1)),
kwargs.get('end_date', date.today()), kwargs.get('order', 'ASC'))
for key, domain in domains.items():
jira = JIRA(domain)
issues = jira.search_issues(search_str, fields=search_field, maxResults=kwargs.get('jira_limit', 50))
if issues:
if kwargs.get('ascii'):
print("{0} issues".format(key))
process_issues(domain, username, issues, **kwargs)
示例12: main
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import search_issues [as 别名]
def main(event, _):
print 'recieved event "%s"' % event
# get creds
config_parser = ConfigParser()
config_parser.read(os.path.join(ROOT_DIR, CREDENTIALS_FILENAME))
jira_username = config_parser.get('jira', 'username')
jira_password = config_parser.get('jira', 'password')
jira_host = config_parser.get('jira', 'host')
# set up query
search_query = ' AND '.join((
'project=WordStream',
'status in (Open, "In Progress", "Dev Complete")',
'text ~ "assertionerror OR keyerror OR valueerror OR notimplementederror"'
))
print 'performing jira search with %s' % search_query
# perform search; count number of matching issues
jira = JIRA(basic_auth=(jira_username, jira_password), server=jira_host)
num_issues = 0
for _ in jira.search_issues(search_query, maxResults=False):
num_issues += 1
print 'found %s issues' % num_issues
# determine timestamp for record
timestamp = datetime.datetime.utcnow()
seconds_since_epoch = int((timestamp - EPOCH).total_seconds())
human_readable_timestamp = timestamp.strftime('%Y-%m-%d %H:%M:%S')
# save number of issues to dynamodb
dynamo = boto3.resource('dynamodb').Table(DYNAMO_DB_TABLENAME)
return dynamo.update_item(
Key={
'source': 'jira',
'timestamp': seconds_since_epoch,
},
UpdateExpression=("add jira_issues :count "
"set timestamp_hr_utc = :timestamp_hr_utc "
),
ExpressionAttributeValues={
':count': num_issues,
':timestamp_hr_utc': human_readable_timestamp,
},
)
示例13: import_issue
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import search_issues [as 别名]
def import_issue(self, message, bug):
"""import lp ____: Creates a Jira ticket based on ___ bug"""
jira = JIRA(
basic_auth=(settings.JIRA_USER, settings.JIRA_PASS),
server=settings.JIRA_HOST,
validate=False,
options={'verify': False}
)
issues = jira.search_issues(self.SEARCH_PATTERN % (
settings.JIRA_PROJ, bug, bug))
if len(issues) > 0:
self.reply(
message,
self.render_jira(issues[0]),
html=True
)
else:
launchpad = Launchpad.login_anonymously(
'will_jira_import',
'production'
)
try:
launchpad.bugs[bug]
except KeyError:
self.reply(message, "That issue does not exist in Launchpad")
return
issue_dict = {
'project': {'key': settings.JIRA_PROJ},
'summary': launchpad.bugs[bug].title,
'description': launchpad.bugs[bug].description,
'issuetype': {'name': 'Bug'},
'customfield_10602': launchpad.bugs[bug].web_link,
'components': [{'id': '18567'}],
'reporter': {'name': self.get_requester_email(message)}
}
self.reply(message, "I need to create that")
new_issue = jira.create_issue(fields=issue_dict)
self.reply(message, self.render_jira(new_issue), html=True)
示例14: jira2txt
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import search_issues [as 别名]
def jira2txt(server, query, output=sys.stdout, csv=False, show_key=True, show_title=False, show_url=True):
def makeRow(wbs, cycles, blank=None):
row = OrderedDict()
row['WBS'] = wbs
for cycle in cycles():
row[cycle] = blank
return row
jira = JIRA(dict(server=server))
table = []
for issue in jira.search_issues(query, maxResults=1000):
if not issue.fields.fixVersions:
print('No release assigned to', issue.key, file=sys.stderr)
continue
cyc = issue.fields.fixVersions[0].name
if issue.fields.customfield_10500:
WBS = issue.fields.customfield_10500
else:
WBS = 'None'
row = makeRow(WBS, cycles, "" if csv else "-")
if show_title and show_key:
row[cyc] = issue.key + ': ' + issue.fields.summary
elif show_title:
row[cyc] = issue.fields.summary
else:
row[cyc] = issue.key
# In CSV mode we can include a URL to the actual issue
if csv and show_url:
row[cyc] = '=HYPERLINK("{}","{}")'.format(server + "/browse/" + issue.key, row[cyc])
table.append(row)
if csv:
writer = DictWriter(output, fieldnames=table[0].keys())
writer.writeheader()
writer.writerows(table)
else:
print(str(tabulate(table, headers='keys', tablefmt='pipe')), file=output)
示例15: AND
# 需要导入模块: from jira import JIRA [as 别名]
# 或者: from jira.JIRA import search_issues [as 别名]
class JIRAProject:
"""
Custom class which represents a JIRA project for DSR report
"""
JQL = 'project="{project}" AND ((created >= "{start}" and created <= "{end}") ' \
'OR (updated >= "{start}" and updated <= "{end}")) order by updated asc'
def __init__(self, config, start_date, end_date):
self.config = config
self.start_date = start_date
self.end_date = end_date
self.jira = JIRA(server=config.url, basic_auth=(config.user,
config.passwd))
self.timezone = pytz.timezone(config.timezone)
self.name = self.jira.project(config.key).name
def __str__(self):
return self.name
def __eq__(self, other):
return self.config.key == other
def get_project_issues(self):
"""
This method returns a list of JIRA issue objects which have
any activities within specified start and end date
s
:return: [JIRAIssue objects]
"""
jira_issues_in_proj = self.jira.search_issues(
JIRAProject.JQL.format(project=self.config.key, start=self.start_date, end=self.end_date))
if jira_issues_in_proj:
project_issues = list()
for issue in jira_issues_in_proj:
project_issue = JIRAIssue(self,
self.jira,
issue.key,
self.start_date,
self.end_date)
project_issues.append(project_issue)
return project_issues