GitLab CE 8.4 Integration
To integrate Cremit with Gitlab CE 8.4, you will need to create an account in GitLab for Cremit for Usenet scanning.
1. Create a GitLab Account
- Log in to the GitLab 8.4 instance as an administrator.
- Navigate to the 'Admin Area'.
- Select 'New User'.
- Enter the account information for Cremit (e.g., username: cremit-scanner, email: cremit-scanner@example.com).
- Click the 'Create user' button.
2. Set Permissions
- Add the Cremit account to the project or group you want to scan.
- Set the permission level to Reporter to allow scanning of the project's code.
- 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
-
Python installation: Python must be installed on your system.
-
Install the requests module:
$ pip install requests
Script Setup
-
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 Cremit
- Log in with the Cremit account.
- Click 'Profile Settings' in the left menu.
- Click 'Account' in the left menu.
- Copy the token in the Reset Private token section.
- Log in to Cremit.
- Click 'Integration' in the left menu.
- Click 'New'.
- Click 'Gitlab'.
- 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.
- Click Submit to complete the integration.