GitLab CE 8.4

Integration GitLab and Cremit

To integrate Cremit with Gitlab CE 8.4, you will need to create an account in GitLab for Cremit for Usenet scanning. > To integrate Cremit with GitLab CE 8.4, you need to create a GitLab account for Cremit to enable Usenet scanning

1. Create a GitLab AccountCopied!

  1. Log in to the GitLab 8.4 instance as an administrator.

  2. Navigate to the 'Admin Area'.

  3. Select 'New User'.

  4. Enter the account information for Cremit (e.g., username: cremit-scanner, email: cremit-scanner@example.com).

  5. Click the 'Create user' button.

2. Set PermissionsCopied!

  1. Add the Cremit account to the project or group you want to scan.

  2. Set the permission level to Reporter to allow scanning of the project's code.

  3. Click 'Add users to group(project)'.

Automatic Permission Setting Script

Use the following Python script to add the same permissions to all projects in bulk. This script grants Reporter permissions to a specific user for all internal and public projects.

Prerequisites
  1. Python installation: Python must be installed on your system.

  2. Install the requests module:

    $ pip install requests
    

Script Setup
  1. Save the script below as invite_group_to_all_visible_repositories.py:

    NEXT_PAGE_PATTERN = re.compile("<([^<>]+)>; rel=\"next\"")
    def get_projects():
        projects = []
        response = get(f"{host}/api/v3/projects/all?order_by=id&sort=asc", headers=headers)
        projects.extend(response.json())
    
        if "Link" in response.headers:
            match_result = NEXT_PAGE_PATTERN.search(response.headers["Link"])
            if(match_result):
                next_page_url = match_result[1]
            else:
                next_page_url = None
        else:
            next_page_url = None
    
        while next_page_url:
            response = get(next_page_url, headers=headers)
            if "Link" in response.headers:
                match_result = NEXT_PAGE_PATTERN.search(response.headers["Link"])
                if(match_result):
                    next_page_url = match_result[1]
                else:
                    next_page_url = None
            else:
                next_page_url = None
            projects.extend(response.json())
    
        return projects
    
    payload = {
        "user_id": user_id,
        "access_level": 20
    }
    
    for project in get_projects():
        project_id = project["id"]
        project_name = project["name"]
        share_proejct_endpoint = host + f"/api/v3/projects/{project_id}/members"
    
        response = post(share_proejct_endpoint, json=payload, headers=headers)
        if response.status_code == 201:
            print(f"user {user_name} is joined to {project_name}")
    

Script Execution

Run the following command in the terminal:

$ python invite_group_to_all_visible_repositories.py {GitLab Host} {PRIVATE TOKEN}

<GitLab Host>: URL of the GitLab instance (e.g., https://gitlab.example.com)
<PRIVATE TOKEN>: GitLab personal access token

3. Integrating with CremitCopied!

  1. Log in with the Cremit account.

  2. Click 'Profile Settings' in the left menu.

  3. Click 'Account' in the left menu.

  4. Copy the token in the Reset Private token section.

  5. Log in to Cremit.

  6. Click 'Integration' in the left menu.

  7. Click 'New'.

  8. Click 'Gitlab'.

  9. Enter the required information.
    Host: Enter the hostname of your GitLab instance.
    Access Token: Enter the Private Token you copied earlier.
    Label: Enter a label to identify this integration.

  10. Click Submit to complete the integration.