How to use the jira.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 pycontribs / jira / tests / tests.py View on Github external
if OAUTH:
                    self.jira_sysadmin = JIRA(oauth={
                        'access_token': '4ul1ETSFo7ybbIxAxzyRal39cTrwEGFv',
                        'access_token_secret':
                            'K83jBZnjnuVRcfjBflrKyThJa0KSjSs2',
                        'consumer_key': CONSUMER_KEY,
                        'key_cert': KEY_CERT_DATA}, logging=False, max_retries=self.max_retries)
                else:
                    if self.CI_JIRA_ADMIN:
                        self.jira_sysadmin = JIRA(self.CI_JIRA_URL,
                                                  basic_auth=(self.CI_JIRA_ADMIN,
                                                              self.CI_JIRA_ADMIN_PASSWORD),
                                                  logging=False, validate=True, max_retries=self.max_retries)
                    else:
                        self.jira_sysadmin = JIRA(self.CI_JIRA_URL,
                                                  logging=False, max_retries=self.max_retries)

                if OAUTH:
                    self.jira_normal = JIRA(oauth={
                        'access_token': 'ZVDgYDyIQqJY8IFlQ446jZaURIz5ECiB',
                        'access_token_secret':
                            '5WbLBybPDg1lqqyFjyXSCsCtAWTwz1eD',
                        'consumer_key': CONSUMER_KEY,
                        'key_cert': KEY_CERT_DATA})
                else:
                    if self.CI_JIRA_ADMIN:
                        self.jira_normal = JIRA(self.CI_JIRA_URL,
                                                basic_auth=(self.CI_JIRA_USER,
                                                            self.CI_JIRA_USER_PASSWORD),
                                                validate=True, logging=False, max_retries=self.max_retries)
                    else:
github pycontribs / jira / tests / tests.py View on Github external
def test_session_with_no_logged_in_user_raises(self):
        anon_jira = JIRA("https://jira.atlassian.com", logging=False)
        self.assertRaises(JIRAError, anon_jira.session)
github saltstack / salt / salt / modules / jira_mod.py View on Github external
def _get_jira(server=None,
              username=None,
              password=None):
    global JIRA
    if not JIRA:
        server, username, password = _get_credentials(server=server,
                                                      username=username,
                                                      password=password)
        JIRA = jira.JIRA(basic_auth=(username, password),
                         server=server,
                         logging=True)  # We want logging
    return JIRA
github StackStorm-Exchange / stackstorm-jira / actions / lib / base.py View on Github external
if auth_method == 'oauth':
            rsa_cert_file = config['rsa_cert_file']
            rsa_key_content = self._get_file_content(file_path=rsa_cert_file)

            oauth_creds = {
                'access_token': config['oauth_token'],
                'access_token_secret': config['oauth_secret'],
                'consumer_key': config['consumer_key'],
                'key_cert': rsa_key_content
            }

            client = JIRA(options=options, oauth=oauth_creds)

        elif auth_method == 'basic':
            basic_creds = (config['username'], config['password'])
            client = JIRA(options=options, basic_auth=basic_creds,
                          validate=config.get('validate', False))

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

        return client
github toabctl / jiracli / jiracli / __init__.py View on Github external
def jira_obj_get(conf):
    verify = conf.getboolean('defaults', 'verify')

    options = {
        'server': conf.get('defaults', 'url'),
        'verify': verify,
    }
    return JIRA(options, basic_auth=(conf.get('defaults', 'user'),
                                     conf.get('defaults', 'password')))
github OSidorenkov / zabbix-jira / jirabix.py View on Github external
def get_transition(issue_key):
    jira_server = {'server': config.jira_server}
    jira = JIRA(options=jira_server, basic_auth=(config.jira_user, config.jira_pass))
    issue = jira.issue(issue_key)
    transitions = jira.transitions(issue)
    for t in transitions:
        if t['name'] == config.jira_transition:
            return t['id']
github all-of-us / raw-data-repository / rdr_service / services / jira_utils.py View on Github external
def _connect_to_jira(self):
        """
        Opens a JIRA API connection based on username/pw
        Will use env vars if localhost, or use cloud config file if not
        """
        options = jira.JIRA.DEFAULT_OPTIONS

        if not self._jira_connection:
            if config.GAE_PROJECT == "localhost":
                if not self._jira_user or not self._jira_password:
                    raise ValueError('Jira user name or password not set in environment.')
            else:
                self.set_jira_credentials_from_config()
                if not self._jira_user or not self._jira_password:
                    raise ValueError('Jira user name or password not set in config.')
            self._jira_connection = jira.JIRA(
                _JIRA_INSTANCE_URL, options=options, basic_auth=(self._jira_user, self._jira_password))
github DefectDojo / django-DefectDojo / dojo / jira_link / views.py View on Github external
def new_jira(request):
    if request.method == 'POST':
        if '_Express' in request.POST:
            return HttpResponseRedirect(reverse('express_jira', ))
        jform = JIRAForm(request.POST, instance=JIRA_Conf())
        if jform.is_valid():
            try:
                jira_server = jform.cleaned_data.get('url').rstrip('/')
                jira_username = jform.cleaned_data.get('username')
                jira_password = jform.cleaned_data.get('password')

                # Instantiate JIRA instance for validating url, username and password
                JIRA(server=jira_server,
                     basic_auth=(jira_username, jira_password))

                new_j = jform.save(commit=False)
                new_j.url = jira_server
                new_j.save()
                messages.add_message(request,
                                     messages.SUCCESS,
                                     'JIRA Configuration Successfully Created.',
                                     extra_tags='alert-success')
                create_notification(event='other',
                                    title='New addition of JIRA URL %s' % jform.cleaned_data.get('url').rstrip('/'),
                                    description='JIRA url "%s" was added by %s' %
                                                (jform.cleaned_data.get('url').rstrip('/'), request.user),
                                    url=request.build_absolute_uri(reverse('jira')),
                                    )
                return HttpResponseRedirect(reverse('jira', ))
github snowflakedb / SnowAlert / src / scripts / jira_bulk_changes.py View on Github external
def connect_jira():
    print('Connecting to Jira...')
    username = input('Jira username: ')
    pwd = getpass.getpass('Jira password: ')
    try:
        jira_api = JIRA(
            f'https://{JIRA_ACCOUNT}.atlassian.net', basic_auth=(username, pwd)
        )
    except Exception as e:
        print('Error connecting to Jira!\n', e)

    return jira_api
github opennode / waldur-mastermind / src / waldur_jira / jira_fix.py View on Github external
data=json.dumps(
            {
                'email': email,
                'fullName': displayName,  # different property for the server one
            }
        ),
    )

    raw_customer_json = json_loads(r)

    if r.status_code != 201:
        raise JIRAError(r.status_code, request=r)
    return Customer(self._options, self._session, raw=raw_customer_json)


JIRA.waldur_add_attachment = add_attachment
JIRA.waldur_service_desk = service_desk
JIRA.waldur_request_types = request_types
JIRA.waldur_search_users = search_users
JIRA.waldur_create_customer_request = create_customer_request
JIRA.waldur_create_customer = create_customer