How to use the jira.client.JIRA function in jira

To help you get started, we’ve selected a few jira examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apache / arrow / dev / tasks / crossbow.py View on Github external
def __init__(self, version, username, password,
                 server='https://issues.apache.org/jira'):
        import jira.client
        self.server = server
        # clean version to the first numbers
        self.version = '.'.join(version.split('.')[:3])
        query = ("project=ARROW "
                 "AND fixVersion='{0}' "
                 "AND status = Resolved "
                 "AND resolution in (Fixed, Done) "
                 "ORDER BY issuetype DESC").format(self.version)
        self.client = jira.client.JIRA({'server': server},
                                       basic_auth=(username, password))
        self.issues = self.client.search_issues(query, maxResults=9999)
github apache / drill / tools / drill-patch-review.py View on Github external
def get_jira():
  options = {
    'server': 'https://issues.apache.org/jira'
  }
  # read the config file
  home=jira_home=os.getenv('HOME')
  home=home.rstrip('/')
  jira_config = dict(line.strip().split('=') for line in open(home + '/jira.ini'))
  jira = JIRA(options,basic_auth=(jira_config['user'], jira_config['password']))
  return jira
github StackStorm-Exchange / stackstorm-jira / sensors / jira_sensor_for_apiv2.py View on Github external
auth_method = self._config['auth_method']

        if auth_method == 'oauth':
            rsa_cert_file = self._config['rsa_cert_file']
            if not os.path.exists(rsa_cert_file):
                raise Exception('Cert file for JIRA OAuth not found at %s.' % rsa_cert_file)
            self._rsa_key = self._read_cert(rsa_cert_file)
            self._poll_interval = self._config.get('poll_interval', self._poll_interval)
            oauth_creds = {
                'access_token': self._config['oauth_token'],
                'access_token_secret': self._config['oauth_secret'],
                'consumer_key': self._config['consumer_key'],
                'key_cert': self._rsa_key
            }

            self._jira_client = JIRA(options={'server': self._jira_url},
                                     oauth=oauth_creds)
        elif auth_method == 'basic':
            basic_creds = (self._config['username'], self._config['password'])
            self._jira_client = JIRA(options={'server': self._jira_url},
                                     basic_auth=basic_creds)

        else:
            msg = ('You must set auth_method to either "oauth"',
                   'or "basic" your jira.yaml config file.')
            raise Exception(msg)

        if self._projects_available is None:
            self._projects_available = set()
            for proj in self._jira_client.projects():
                self._projects_available.add(proj.key)
        self._project = self._config.get('project', None)
github pycontribs / jira / examples / example.py View on Github external
from jira.client import JIRA
import pprint as pp

jira = JIRA(basic_auth=('admin', 'admin'))

i = jira.project('BULK')
props = jira.application_properties()
#jira.set_application_property('jira.clone.prefix', 'horseflesh')

meta = jira.attachment_meta()

# auto issue lookup
issue = jira.issue('TST-3')
print 'Issue {} reported by {} has {} comments.'.format(
    issue.key, issue.fields.assignee.name, issue.fields.comment.total
)

# auto project lookup
project = jira.project('TST')
print 'Project {} has key {} and {} components.'.format(
github fsalum / slackbot-python / plugins / atlassian-jira.py View on Github external
def atlassian_jira(user, action, parameter):

    jira_username = config.get("jira_username")
    jira_password = config.get("jira_password")

    options = {
        'server': 'https://agapigroup.atlassian.net',
    }
    jira = JIRA(options, basic_auth=(jira_username, jira_password))

    if action == 'projects':
        return projects(jira, parameter)
    elif action == 'info':
        return info(jira, parameter)
    elif action == 'assign':
        return assign(jira, parameter)
    elif action == 'comment':
        return comment(user, jira, parameter)
    elif action == 'create':
        return create(user, jira, parameter)
    elif action == 'close':
        return close(user, jira, parameter)
github Yelp / elastalert / elastalert / alerts.py View on Github external
self.client = None

        if self.bump_in_statuses and self.bump_not_in_statuses:
            msg = 'Both jira_bump_in_statuses (%s) and jira_bump_not_in_statuses (%s) are set.' % \
                  (','.join(self.bump_in_statuses), ','.join(self.bump_not_in_statuses))
            intersection = list(set(self.bump_in_statuses) & set(self.bump_in_statuses))
            if intersection:
                msg = '%s Both have common statuses of (%s). As such, no tickets will ever be found.' % (
                    msg, ','.join(intersection))
            msg += ' This should be simplified to use only one or the other.'
            logging.warning(msg)

        self.reset_jira_args()

        try:
            self.client = JIRA(self.server, basic_auth=(self.user, self.password))
            self.get_priorities()
            self.jira_fields = self.client.fields()
            self.get_arbitrary_fields()
        except JIRAError as e:
            # JIRAError may contain HTML, pass along only first 1024 chars
            raise EAException("Error connecting to JIRA: %s" % (str(e)[:1024])).with_traceback(sys.exc_info()[2])

        self.set_priority()
github apache / griffin / merge_pr.py View on Github external
def resolve_jira_issue(merge_branches, comment, default_jira_id="5"):
    asf_jira = jira.client.JIRA({'server': JIRA_API_BASE},
                                basic_auth=(JIRA_USERNAME, JIRA_PASSWORD))

    jira_id = raw_input("Enter a Griffin JIRA number id [%s]: " % default_jira_id)
    if jira_id == "":
        jira_id = default_jira_id

    try:
        issue = asf_jira.issue("%s" % (jira_id))
    except Exception as e:
        fail("ASF JIRA could not find %s\n%s" % (jira_id, e))

    cur_status = issue.fields.status.name
    cur_summary = issue.fields.summary
    cur_assignee = issue.fields.assignee
    if cur_assignee is None:
        cur_assignee = "NOT ASSIGNED!!!"