예제 #1
0
def test_gitlab_user_agent(kwargs, expected_agent):
    gl = Gitlab("http://localhost", **kwargs)
    assert gl.headers["User-Agent"] == expected_agent
예제 #2
0
 def _ini_gitlab_api(self):
     self.gitlab_api = Gitlab(
             url='https://gitlab-ee.sc.dlr.de',
             private_token=self._config['GITLAB']['token'])
예제 #3
0
 def __init__(self, server, token, trigger_token):
     self.server = server
     self.token = token
     self.gl = Gitlab(self.server, self.token)
     self.headers = {"PRIVATE-TOKEN": self.token}
     self.trigger_token = trigger_token
예제 #4
0
 def test___init__with_oauth_token(self):
     gitlab = Gitlab('http://localhost:10080',
                     verify_ssl=False,
                     oauth_token='something')
     self.assertEqual('something', gitlab.oauth_token)
     self.assertEqual({'Authorization': 'Bearer something'}, gitlab.headers)
예제 #5
0
 def test___init__with_token(self):
     gitlab = Gitlab('http://localhost:10080',
                     verify_ssl=False,
                     token='something')
     self.assertEqual('something', gitlab.token)
     self.assertEqual({'PRIVATE-TOKEN': 'something'}, gitlab.headers)
예제 #6
0
project = config['gitlab']['project']

db_driver = config['db']['db_driver']
db_server = config['db']['server']
db_database = config['db']['database']

version_branch = config['branch']['version']
user_story_branch = config['branch']['user_story']
bug_branch = config['branch']['bug']
'''
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Место подключение
'''
# курсор коннекта к базе данных
cursor = connect_db(db_driver, db_server, db_database)
gl = Gitlab(url, token)
gl.auth()
'''
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Исполнение основной логики
'''


def search_for_merge_requests(group):
    # сбор мерж реквестов пустых и назначенных
    empty_merge_requests_iid = dict()
    empty_merge_requests_author_id = dict()
    not_empty_merge_requests = dict()
    mr_all = group.mergerequests.list()
    for mr in mr_all:
        if str(mr.merged_at) == "None":
예제 #7
0
 def setUp(self):
     self.user = os.environ.get('gitlab_user', 'root')
     self.password = os.environ.get('gitlab_password', '5iveL!fe')
     self.host = os.environ.get('gitlab_host', 'http://localhost:10080')
     self.gitlab = Gitlab(host=self.host, verify_ssl=False)
     self.gitlab.login(user=self.user, password=self.password)
예제 #8
0
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from gitlab import Gitlab

app = Flask(__name__)
db = SQLAlchemy()
gl = Gitlab('https://gitlab.com/', private_token='mpFQR4rh6EsP4UyP1wMK')
예제 #9
0
 def get_collaborators(self, repo_name):
     gl = Gitlab(url=self.url, private_token=self.auth_token)
     project_id = self.__project_id(project_name=repo_name)
     project = gl.projects.get(project_id)
     users = project.members.list()
     return [user.username for user in users]
예제 #10
0
import os

from gitlab import Gitlab

host = os.environ.get('gitlab_host', 'http://gitlab:80')
user = os.environ.get('gitlab_user', 'root')
password = os.environ.get('gitlab_password', '5iveL!fe')

gitlab = Gitlab(host=host, verify_ssl=False)

gitlab_responding = False
while not gitlab_responding:
    try:
        response = gitlab.login(user=user, password=password)
        gitlab_responding = True
    except:
        pass

exit(0)
예제 #11
0
def build_gitlab_service(access_token):
    gitlab = Gitlab(GITLAB_INSTANCE, private_token=access_token)
    return gitlab
예제 #12
0
#!/usr/bin/env python3

import os
import sys
import json
from gitlab import Gitlab

g = Gitlab('https://gitlab.com', job_token=os.environ['CI_JOB_TOKEN'])
repo = g.projects.get(19694297)
open_issues = repo.issues.list(state='opened', labels=['out-of-date'])

for line in sys.stdin:
    this = json.loads(line)
    print(this)
    if this['event'] != 'updated':
        continue
    title = '%s: updated from %s to %s' % (this['name'], this['old_version'],
                                           this['version'])
    opened = False
    for issue in open_issues:
        if issue.title.startswith(this['name'] + ': '):
            opened = True
            if issue.title != title:
                editable_issue = repo.issues.get(issue.iid, lazy=True)
                editable_issue.title = title
                editable_issue.save()
            break
    if not opened:
        repo.issues.create({
            'title': title,
            'labels': 'out-of-date',
def registered_gitlab_client():
    client = Gitlab(os.environ["GITLAB_URL"],
                    api_version=4,
                    oauth_token=os.environ["GITLAB_TOKEN"])
    client.auth()
    return client
def anonymous_gitlab_client():
    client = Gitlab(os.environ["GITLAB_URL"], api_version=4)
    return client
예제 #15
0
 def __init__(self, config: Config):
     self.client = Gitlab(url=config.gitlab_base_url,
                          private_token=config.gitlab_token)
     self.group = config.gitlab_group
예제 #16
0
 def get_repo_url(self, repo_name: str):
     project_id = self.__project_id(project_name=repo_name)
     gl = Gitlab(url=self.url, private_token=self.auth_token)
     project = gl.projects.get(project_id)
     return project.http_url_to_repo
예제 #17
0
import os
import sys

from github import Github
from gitlab import Gitlab

if len(sys.argv) != 3:
    print("Usage: gitlab_migration.py github_user/repo gitlab_user/repo")
    print("Make sure to set $GITHUB_TOKEN and $GITLAB_TOKEN")
    sys.exit(1)

gh = Github(os.getenv("GITHUB_TOKEN"))
gh_repo = gh.get_repo(sys.argv[0])
gh_issues = [issue for issue in gh_repo.get_issues()]

gl = Gitlab("https://gitlab.com", private_token=os.getenv("GITLAB_TOKEN"))
taskforge = gl.projects.get(sys.argv[1])

for issue in gh_issues:
    print("Creating ticket:")
    print("\tSummary:", issue.title)
    print("\tDescription:", issue.body)

    gl_issue = taskforge.issues.create(
        {
            "title": issue.title,
            "description": issue.body
        }, )
    gl_issue.labels = [label.name for label in issue.get_labels()]

    for comment in issue.get_comments():
예제 #18
0
def event_processor_thread(config, credentials, flag, queue):
    """
    Event processing thread. Gathers calendar IDs, signals the synchronization
    event "flag" to wake the main thread, then enters the event handling
    loop.
    """

    logger = logging.getLogger('calmgr')

    logger.info("Event processing thread starting...")

    # set success flag to true initially
    current_thread().successful_init = True

    # instantiate google api client
    service = discovery.build('calendar', 'v3', credentials=credentials)

    # instantiate gitlab api client if enabled
    gitlab = None
    if config['gitlabApi']['enable']:
        try:
            from gitlab import Gitlab
            gitlab = Gitlab(config['gitlabApi']['url'],
                            config['gitlabApi']['token'])
        except Exception as e:
            logger.error("Failed to instantiate GitLab API client.")
            logger.exception(e)
            current_thread().successful_init = False

    # get calendar mappings
    logger.info("Initializing calendar ID mapping...")
    try:
        calIdMap = get_cal_id_map(service, config)
    except Exception as e:
        logger.error("Failed to load calendar ID mapping.")
        logger.exception(e)
        current_thread().successful_init = False

    for calName, calId in calIdMap.items():
        logger.info("ID for calendar \"%s\" is \"%s\"" % (calName, calId))

    # wake main thread
    flag.set()

    # if successful, start event loop
    if current_thread().successful_init:

        logger.info("Entering event loop...")

        while True:

            # try to get event from queue. break loop on thread_terminator.
            event = queue.get()
            if isinstance(event, thread_terminator):
                queue.task_done()
                break

            # process event, logging any error
            try:
                handle_event(event, service, gitlab, calIdMap, config)
            except Exception as e:
                logger.error("Unhandled exception while processing event.")
                logger.exception(e)

            queue.task_done()
예제 #19
0
 def __init__(self):
     self.root_group_path = 'nextmod/mod'
     self.gl = Gitlab('https://gitlab.com')
예제 #20
0
import common
import config
from github import Github
from gitlab import Gitlab
import os
import json
import re
import shutil
import urllib.request
import uuid
import xmltodict
import zipfile

gh = Github(config.github_username, config.github_password)
gl = Gitlab('https://gitlab.com',
            private_token=config.gitlab_private_access_token)
gl.auth()


def get_latest_release(module, include_prereleases=True):
    if common.GitService(module['git']['service']) == common.GitService.GitHub:
        try:
            repo = gh.get_repo(
                f'{module["git"]["org_name"]}/{module["git"]["repo_name"]}')
        except:
            print(
                f'[Error] Unable to find repo: {module["git"]["org_name"]}/{module["git"]["repo_name"]}'
            )
            return None

        releases = repo.get_releases()
예제 #21
0
 def set_api(self, host, access_token):
     self.api = Gitlab(host, oauth_token=access_token)
예제 #22
0
파일: git.py 프로젝트: bmendesl/521Noturno
from flask import Flask, Blueprint, render_template
from gitlab import Gitlab

gitlab = Blueprint('gittlab', __name__, url_prefix='/gitlab')

con = Gitlab('http://172.17.0.3', private_token='x9wyRGV97wZa1NeG23DR')

@gitlab.route('')
def index():
    users = con.users.list()
    projects = con.projects.list()
    return render_template('gitlab.html', users=users, projects=projects)


예제 #23
0
 def test___init__with_https(self):
     gitlab = Gitlab('https://localhost:10080',
                     verify_ssl=False,
                     oauth_token='something')
     self.assertEqual('https://localhost:10080', gitlab.host)
예제 #24
0
def get_gitlab_client():
    global _gitlab_client
    if _gitlab_client is None:
        _gitlan_client = Gitlab(GITLAB_URL, token=GITLAB_TOKEN)
    return _gitlan_client
예제 #25
0
    def setUp(self):
        unitest_python_version_check_requirement(self)

        self.mock_module = FakeAnsibleModule()

        self.gitlab_instance = Gitlab("http://localhost", private_token="private_token", api_version=4)
예제 #26
0
def add_comment_merge_request(project_id, merge_request_id, note):
    client = Gitlab(GITLAB_URL, token=GITLAB_TOKEN)
    return client.addcommenttomergerequest(project_id, merge_request_id, note)
def _gitlab_instance():
    with open(GITLAB_TOKEN_FILE) as token_file:
        token = token_file.readline().strip()
    return Gitlab(GITLAB_HOST, private_token=token, api_version=4)
예제 #28
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import json
import re
from gitlab import Gitlab

from config import Config

gl = Gitlab(Config.gitlab_url, Config.gitlab_token)
project = gl.projects.get('tsalzmann/gl-test-project')


def issue_to_pm(issue):
    regex = r'^PM-\d+-\d+'
    title = issue.title
    match = re.search(regex, title)
    if match:
        return match.group(0)

    return ''


def get_new_issues(issue, existing_pms):
    if issue['id'] in existing_pms:
        return False
    else:
        return True


def get_company(str):
예제 #29
0
파일: gitlab.py 프로젝트: tkeri/fuzzinator
 def __init__(self, url, project, private_token=None):
     gl = Gitlab(url, private_token=private_token)
     gl.auth()
     self.project = gl.projects.get(gl.search('projects', project)[0]['id'])
 def __init__(self, gitlab_url, api_token, namespace, project_slug):
     self.gitlab_url = gitlab_url
     self.api_token = api_token
     self.namespace = namespace
     self.project_slug = project_slug
     self.client = Gitlab(self.gitlab_url, self.api_token, ssl_verify=False)