当前位置: 首页>>代码示例>>Python>>正文


Python gitlab.com方法代码示例

本文整理汇总了Python中gitlab.com方法的典型用法代码示例。如果您正苦于以下问题:Python gitlab.com方法的具体用法?Python gitlab.com怎么用?Python gitlab.com使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gitlab的用法示例。


在下文中一共展示了gitlab.com方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: import gitlab [as 别名]
# 或者: from gitlab import com [as 别名]
def main():
    if 2 > len(sys.argv) > 3:
        usage()

    project_name = sys.argv[1]
    if len(sys.argv) > 2:
        branch_name = sys.argv[2]
    else:
        branch_name = 'master'

    gl_token = os.getenv('GITLAB_TOKEN')
    if gl_token is None:
        print('GITLAB_TOKEN not set!')
        exit(1)
    gl = gitlab.Gitlab('https://gitlab.com/', gl_token)

    project = gl.projects.get(project_name)
    branch = project.branches.get(branch_name)
    top_commit = project.commits.get(branch.commit['short_id'])

    if top_commit.last_pipeline['status'] == 'success':
        print(top_commit.short_id)
    else:
        exit(1) 
开发者ID:maxking,项目名称:docker-mailman,代码行数:26,代码来源:get_latest_ref.py

示例2: user_handler

# 需要导入模块: import gitlab [as 别名]
# 或者: from gitlab import com [as 别名]
def user_handler(_, request):
    if not request.headers.get("Authorization") == "Bearer foobar":
        return {"status_code": 401}

    return {
        "status_code": 200,
        "headers": {"Content-Type": "application/json",},
        "content": json.dumps(
            {
                "id": 1,
                "username": "john_smith",
                "email": "john@example.com",
                "name": "John Smith",
                "state": "active",
            }
        ),
    } 
开发者ID:quay,项目名称:quay,代码行数:19,代码来源:gitlabmock.py

示例3: project_handler

# 需要导入模块: import gitlab [as 别名]
# 或者: from gitlab import com [as 别名]
def project_handler(_, request):
    if not request.headers.get("Authorization") == "Bearer foobar":
        return {"status_code": 401}

    return {
        "status_code": 200,
        "headers": {"Content-Type": "application/json",},
        "content": json.dumps(
            {
                "id": 4,
                "description": None,
                "default_branch": "master",
                "visibility": "private",
                "path_with_namespace": "someorg/somerepo",
                "ssh_url_to_repo": "git@example.com:someorg/somerepo.git",
                "web_url": "http://example.com/someorg/somerepo",
            }
        ),
    } 
开发者ID:quay,项目名称:quay,代码行数:21,代码来源:gitlabmock.py

示例4: namespaces_handler

# 需要导入模块: import gitlab [as 别名]
# 或者: from gitlab import com [as 别名]
def namespaces_handler(_, request):
    if not request.headers.get("Authorization") == "Bearer foobar":
        return {"status_code": 401}

    return {
        "status_code": 200,
        "headers": {"Content-Type": "application/json",},
        "content": json.dumps(
            [
                {
                    "id": 2,
                    "name": "someorg",
                    "path": "someorg",
                    "kind": "group",
                    "full_path": "someorg",
                    "parent_id": None,
                    "web_url": "http://gitlab.com/groups/someorg",
                    "members_count_with_descendants": 2,
                }
            ]
        ),
    } 
开发者ID:quay,项目名称:quay,代码行数:24,代码来源:gitlabmock.py

示例5: user_projects_list_handler

# 需要导入模块: import gitlab [as 别名]
# 或者: from gitlab import com [as 别名]
def user_projects_list_handler(_, request):
    if not request.headers.get("Authorization") == "Bearer foobar":
        return {"status_code": 401}

    return {
        "status_code": 200,
        "headers": {"Content-Type": "application/json",},
        "content": json.dumps(
            [
                {
                    "id": 2,
                    "name": "Another project",
                    "description": None,
                    "default_branch": "master",
                    "visibility": "public",
                    "path": "anotherproject",
                    "path_with_namespace": "knownuser/anotherproject",
                    "last_activity_at": "2013-09-30T13:46:02Z",
                    "web_url": "http://example.com/knownuser/anotherproject",
                }
            ]
        ),
    } 
开发者ID:quay,项目名称:quay,代码行数:25,代码来源:gitlabmock.py

示例6: removeUser

# 需要导入模块: import gitlab [as 别名]
# 或者: from gitlab import com [as 别名]
def removeUser(self):
        GITLAB_TOKEN = Token.objects.values().get(key='GITLAB_TOKEN')['value']
        gl = gitlab.Gitlab('https://gitlab.com/', GITLAB_TOKEN)
        gl.auth()
        group = gl.groups.get('amfoss')
        userID = gl.users.list(username=self.username)[0].id
        group.members.delete(userID) 
开发者ID:amfoss,项目名称:cms,代码行数:9,代码来源:gitlab.py

示例7: addUser

# 需要导入模块: import gitlab [as 别名]
# 或者: from gitlab import com [as 别名]
def addUser(self):
        GITLAB_TOKEN = Token.objects.values().get(key='GITLAB_TOKEN')['value']
        gl = gitlab.Gitlab('https://gitlab.com/', GITLAB_TOKEN)
        gl.auth()
        group = gl.groups.get('amfoss')
        userID = gl.users.list(username=self.username)[0].id
        group.members.create({'user_id': userID, 'access_level': gitlab.GUEST_ACCESS}) 
开发者ID:amfoss,项目名称:cms,代码行数:9,代码来源:gitlab.py

示例8: checkIfUserExists

# 需要导入模块: import gitlab [as 别名]
# 或者: from gitlab import com [as 别名]
def checkIfUserExists(self):
        GITLAB_TOKEN = Token.objects.values().get(key='GITLAB_TOKEN')['value']
        gl = gitlab.Gitlab('https://gitlab.com/', GITLAB_TOKEN)
        gl.auth()
        group = gl.groups.get('amfoss')
        userID = gl.users.list(username=self.username)[0].id
        try:
            member = group.members.get(userID)
            if member:
                return True
            else:
                return False
        except:
            return False 
开发者ID:amfoss,项目名称:cms,代码行数:16,代码来源:gitlab.py

示例9: project_branch_handler

# 需要导入模块: import gitlab [as 别名]
# 或者: from gitlab import com [as 别名]
def project_branch_handler(_, request):
    if not request.headers.get("Authorization") == "Bearer foobar":
        return {"status_code": 401}

    return {
        "status_code": 200,
        "headers": {"Content-Type": "application/json",},
        "content": json.dumps(
            {
                "name": "master",
                "merged": True,
                "protected": True,
                "developers_can_push": False,
                "developers_can_merge": False,
                "commit": {
                    "author_email": "john@example.com",
                    "author_name": "John Smith",
                    "authored_date": "2012-06-27T05:51:39-07:00",
                    "committed_date": "2012-06-28T03:44:20-07:00",
                    "committer_email": "john@example.com",
                    "committer_name": "John Smith",
                    "id": "60a8ff033665e1207714d6670fcd7b65304ec02f",
                    "short_id": "7b5c3cc",
                    "title": "add projects API",
                    "message": "add projects API",
                    "parent_ids": ["4ad91d3c1144c406e50c7b33bae684bd6837faf8",],
                },
            }
        ),
    } 
开发者ID:quay,项目名称:quay,代码行数:32,代码来源:gitlabmock.py

示例10: commit_handler

# 需要导入模块: import gitlab [as 别名]
# 或者: from gitlab import com [as 别名]
def commit_handler(_, request):
    if not request.headers.get("Authorization") == "Bearer foobar":
        return {"status_code": 401}

    return {
        "status_code": 200,
        "headers": {"Content-Type": "application/json",},
        "content": json.dumps(
            {
                "id": "60a8ff033665e1207714d6670fcd7b65304ec02f",
                "short_id": "60a8ff03366",
                "title": "Sanitize for network graph",
                "author_name": "someguy",
                "author_email": "some.guy@gmail.com",
                "committer_name": "Some Guy",
                "committer_email": "some.guy@gmail.com",
                "created_at": "2012-09-20T09:06:12+03:00",
                "message": "Sanitize for network graph",
                "committed_date": "2012-09-20T09:06:12+03:00",
                "authored_date": "2012-09-20T09:06:12+03:00",
                "parent_ids": ["ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"],
                "last_pipeline": {
                    "id": 8,
                    "ref": "master",
                    "sha": "2dc6aa325a317eda67812f05600bdf0fcdc70ab0",
                    "status": "created",
                },
                "stats": {"additions": 15, "deletions": 10, "total": 25},
                "status": "running",
            }
        ),
    } 
开发者ID:quay,项目名称:quay,代码行数:34,代码来源:gitlabmock.py

示例11: create_hook_handler

# 需要导入模块: import gitlab [as 别名]
# 或者: from gitlab import com [as 别名]
def create_hook_handler(_, request):
    if not request.headers.get("Authorization") == "Bearer foobar":
        return {"status_code": 401}

    return {
        "status_code": 200,
        "headers": {"Content-Type": "application/json",},
        "content": json.dumps(
            {
                "id": 1,
                "url": "http://example.com/hook",
                "project_id": 4,
                "push_events": True,
                "issues_events": True,
                "confidential_issues_events": True,
                "merge_requests_events": True,
                "tag_push_events": True,
                "note_events": True,
                "job_events": True,
                "pipeline_events": True,
                "wiki_page_events": True,
                "enable_ssl_verification": True,
                "created_at": "2012-10-12T17:04:47Z",
            }
        ),
    } 
开发者ID:quay,项目名称:quay,代码行数:28,代码来源:gitlabmock.py

示例12: get_projects_handler

# 需要导入模块: import gitlab [as 别名]
# 或者: from gitlab import com [as 别名]
def get_projects_handler(add_permissions_block):
    @urlmatch(netloc=r"fakegitlab", path=r"/api/v4/groups/2/projects$")
    def projects_handler(_, request):
        if not request.headers.get("Authorization") == "Bearer foobar":
            return {"status_code": 401}

        permissions_block = {
            "project_access": {"access_level": 10, "notification_level": 3},
            "group_access": {"access_level": 20, "notification_level": 3},
        }

        return {
            "status_code": 200,
            "headers": {"Content-Type": "application/json",},
            "content": json.dumps(
                [
                    {
                        "id": 4,
                        "name": "Some project",
                        "description": None,
                        "default_branch": "master",
                        "visibility": "private",
                        "path": "someproject",
                        "path_with_namespace": "someorg/someproject",
                        "last_activity_at": "2013-09-30T13:46:02Z",
                        "web_url": "http://example.com/someorg/someproject",
                        "permissions": permissions_block if add_permissions_block else None,
                    },
                    {
                        "id": 5,
                        "name": "Another project",
                        "description": None,
                        "default_branch": "master",
                        "visibility": "public",
                        "path": "anotherproject",
                        "path_with_namespace": "someorg/anotherproject",
                        "last_activity_at": "2013-09-30T13:46:02Z",
                        "web_url": "http://example.com/someorg/anotherproject",
                    },
                ]
            ),
        }

    return projects_handler 
开发者ID:quay,项目名称:quay,代码行数:46,代码来源:gitlabmock.py

示例13: report_issue_from_testexecution

# 需要导入模块: import gitlab [as 别名]
# 或者: from gitlab import com [as 别名]
def report_issue_from_testexecution(self, execution, user):
        """
            JIRA Project == Kiwi TCMS Product, otherwise defaults to the first found
            Issue Type == Bug or the first one found

            If 1-click bug report doesn't work then fall back to manual
            reporting!

            For the HTML API description see:
            https://confluence.atlassian.com/display/JIRA050/Creating+Issues+via+direct+HTML+links
        """
        try:
            project = self.rpc.project(execution.run.plan.product.name)
        except jira.exceptions.JIRAError:
            project = self.rpc.projects()[0]

        try:
            issue_type = self.rpc.issue_type_by_name('Bug')
        except KeyError:
            issue_type = self.rpc.issue_types()[0]

        try:
            new_issue = self.rpc.create_issue(
                project=project.id,
                issuetype={'name': issue_type.name},
                summary='Failed test: %s' % execution.case.summary,
                description=self._report_comment(execution),
            )
            new_url = self.bug_system.base_url + "/browse/" + new_issue.key

            # add a link reference that will be shown in the UI
            LinkReference.objects.get_or_create(
                execution=execution,
                url=new_url,
                is_defect=True,
            )

            return new_url
        except jira.exceptions.JIRAError:
            pass

        args = {
            'pid': project.id,
            'issuetype': issue_type.id,
            'summary': 'Failed test: %s' % execution.case.summary,
            'description': self._report_comment(execution),
        }

        url = self.bug_system.base_url
        if not url.endswith('/'):
            url += '/'

        return url + '/secure/CreateIssueDetails!init.jspa?' + urlencode(args, True) 
开发者ID:kiwitcms,项目名称:Kiwi,代码行数:55,代码来源:types.py


注:本文中的gitlab.com方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。