Beispiel #1
0
 def __init__(self, project_name):
     global config
     self.mongo_db = mongodb_class.mongoDB(project_name)
     """将工作日志独立记录"""
     self.mongo_db_worklogs = mongodb_class.mongoDB("WORK_LOGS")
     self.jira = JIRA(config.get('JIRA', 'url'),
                      basic_auth=(config.get('JIRA', 'user'),
                                  config.get('JIRA', 'password')))
     self.gh = GreenHopper({'server': config.get('JIRA', 'url')},
                           basic_auth=(config.get('JIRA', 'user'),
                                       config.get('JIRA', 'password')))
     self.name = project_name
     self.project = self.jira.project(self.name)
     self.pj_name = u"%s" % self.project.name
     self.pj_manager = u"%s" % self.project.lead.displayName
     """获取项目版本信息
     """
     _versions = self.jira.project_versions(self.name)
     self.version = {}
     self.sprints = self._get_sprints()
     for _v in _versions:
         _key = (u"%s" % _v).replace('.', '^')
         if not self.version.has_key(_key):
             self.version[_key] = {}
         self.version[_key][u"id"] = _v.id
         self.version[_key]['startDate'] = ""
         self.version[_key]['releaseDate'] = ""
         if 'startDate' in dir(_v):
             self.version[_key]['startDate'] = _v.startDate
         if 'releaseDate' in dir(_v):
             self.version[_key]['releaseDate'] = _v.releaseDate
         self.mongo_db.handler("project", "update",
                               {"version": _key}, dict({"version": _key}, **self.version[_key]))
     self.issue = None
Beispiel #2
0
 def __init__(self, project_name):
     self.mongo_db = mongodb_class.mongoDB(project_name)
     self.jira = JIRA('http://172.16.60.13:8080', basic_auth=('shenwei','sw64419'))
     self.gh = GreenHopper({'server': 'http://172.16.60.13:8080'}, basic_auth=('shenwei', 'sw64419'))
     self.name = project_name
     self.project = self.jira.project(self.name)
     self.pj_name = u"%s" % self.project.name
     self.pj_manager = u"%s" % self.project.lead.displayName
     """获取项目版本信息
     """
     _versions = self.jira.project_versions(self.name)
     self.version = {}
     self.sprints = self._get_sprints()
     for _v in _versions:
         _key = (u"%s" % _v).replace('.', '^')
         if not self.version.has_key(_key):
             self.version[_key] = {}
         self.version[_key][u"id"] = _v.id
         self.version[_key]['startDate'] = ""
         self.version[_key]['releaseDate'] = ""
         if 'startDate' in dir(_v):
             self.version[_key]['startDate'] = _v.startDate
         if 'releaseDate' in dir(_v):
             self.version[_key]['releaseDate'] = _v.releaseDate
         self.mongo_db.handler("project", "update",
                               {"version": _key}, dict({"version": _key}, **self.version[_key]))
     self.issue = None
Beispiel #3
0
def jira_login():
	username = raw_input("Jira username: "******"Jira password: "******"Company (as used in Jira URL): ")
	jira_url = "https://" + company + ".jira.com"
	options = {'server': jira_url}
	gh = GreenHopper(options, basic_auth=(username, password))
	return gh
Beispiel #4
0
 def startSession(self):
     #now make the connection
     options = {'server': self.__jiraURL, 'verify': False}
     self.__jira = JIRA(options,
                        basic_auth=(self.__jiraUser, self.__jiraPassword))
     self.__greenhopper = GreenHopper(options,
                                      basic_auth=(self.__jiraUser,
                                                  self.__jiraPassword))
Beispiel #5
0
def getJiraClient():
    jira=GreenHopper(options={'server': JIRA_SERVER}, oauth={
               'access_token': con_credentials.get('ACCESS_TOKEN'),
               'access_token_secret': con_credentials.get('ACCESS_TOKEN_SECRET'),
               'consumer_key': CONSUMER_KEY,
               'key_cert': RSA_KEY
               })
    return jira
Beispiel #6
0
 def _jira_login(self, endpoint: str, user: str, password: str) -> GreenHopper:
     try:
         basic_auth = (user, password)
         jira = GreenHopper({'server': endpoint}, basic_auth=basic_auth)
         # pylint: disable=protected-access
         if "JSESSIONID" in jira._session.cookies:
             # drop basic auth if we have a cookie (for performance)
             jira._session.auth = None
         return jira
     except JIRAError as e:
         raise e
Beispiel #7
0
def jira_login(endpoint, user=None):
    try:
        basic_auth = None
        if user:
            if sys.stdin.isatty():
                password = getpass.getpass(stream=sys.stderr)
            else:
                password = sys.stdin.readline().rstrip()
            basic_auth = (user, password)
        try:
            jira = GreenHopper({'server': endpoint}, basic_auth=basic_auth)
        except JIRAError:
            sys.stderr.write("warn: Autentication to JIRA failed," +
                             " continuing unauthenticated\n")
            jira = GreenHopper({'server': endpoint})
        # pylint: disable=protected-access
        if "JSESSIONID" in jira._session.cookies:
            # drop basic auth if we have a cookie (for performance)
            jira._session.auth = None
        return jira
    except JIRAError as exn:
        sys.stderr.write("Connection to JIRA failed: %s: %s\n" %
                         (exn.response.status_code, exn.response.reason))
        exit(4)
Beispiel #8
0
 def greenhopper(self):
     return GreenHopper(options={
         'server': self.get('root'),
         'verify': False
     },
                        oauth={
                            'access_token':
                            self.get('access_token'),
                            'access_token_secret':
                            self.get('access_token_secret'),
                            'consumer_key':
                            self.get('consumer_key'),
                            'key_cert':
                            self.rsa_key
                        })
Beispiel #9
0
	def GreenHopper_connect(self, username, password, options):
		print('authenticating with JIRA Greenhopper...')
		gh = GreenHopper(basic_auth=(username, password), options = options)
		print('authenticated with GreenHopper. ')
		return gh
Beispiel #10
0
#   ===============================
#

from jira import JIRA
from jira.client import GreenHopper
import io

import types, json
import sys

options = {
    'server': 'http://jira.chinacloud.com.cn',
}

jira = JIRA('http://jira.chinacloud.com.cn', basic_auth=('shenwei', 'sw64419'))
gh = GreenHopper(options, basic_auth=('shenwei', 'sw64419'))
fd = io.open('date_desc.txt', 'w+', encoding='utf-8')


def _print(s):
    global fd

    fd.write(u"%s" % s)
    fd.write(u"\n")
    print(s)


def test(custom_name):
    # Fetch all fields
    allfields = jira.fields()
    # Make a map from field name -> field id
Beispiel #11
0
                    filename=file_path)

jira_config = get_jira_config()
jira_pwd = (base64.b64decode(jira_config['pwd'])).decode('utf-8')
myjira = JIRA(
    jira_config['url'],
    basic_auth=(jira_config['user'], (base64.b64decode(jira_config['pwd'])).decode('utf-8')),
    logging=True,
    validate=True,
    async_=True,
    async_workers=20,
    options={'verify': False},
)

greenhopper = GreenHopper(
    options={'server': CI_JIRA_URL, 'verify': False},
    basic_auth=(jira_config['user'], jira_pwd)
)


class Testclient(object):
    """
    testrail client, send request, and get info and data
    """
    def __init__(self, base_url):
        self.user = xxxxxxxxx
        self.password = xxxxxxxxx
        if not base_url.endswith('/'):
            base_url += '/'
        self.__url = base_url + 'index.php?/api/v2/'

    def send_get(self, uri, filepath=None):
Beispiel #12
0
# This script shows how to use the client in anonymous mode
# against jira.atlassian.com.
from six import print_ as print

from jira.client import GreenHopper

# By default, the client will connect to a JIRA instance started from the Atlassian Plugin SDK
# (see https://developer.atlassian.com/display/DOCS/Installing+the+Atlassian+Plugin+SDK for details).
# Override this with the options parameter.
# GreenHopper is a plugin in a JIRA instance
options = {'server': 'https://jira.atlassian.com'}
gh = GreenHopper(options)

# Get all boards viewable by anonymous users.
boards = gh.boards()

# Get the sprints in a specific board
board_id = 441
print("GreenHopper board: %s (%s)" % (boards[0].name, board_id))
sprints = gh.sprints(board_id)

# List the incomplete issues in each sprint
for sprint in sprints:
    sprint_id = sprint.id
    print("Sprint: %s" % sprint.name)
    incompleted_issues = gh.incompleted_issues(board_id, sprint_id)
    print("Incomplete issues: %s" % ', '.join(issue.key
                                              for issue in incompleted_issues))
def jgreencon(jira_param):
    """ This is the methos used as jira connector """
    jcon = GreenHopper(options={'server': jira_param[0]},
                       basic_auth=(jira_param[1], jira_param[2]))
    return jcon
Beispiel #14
0
 def connect(self):
     self._jira_client = GreenHopper(basic_auth=(self._username,
                                                 self._password),
                                     options={'server': self._server_url})