Projects¶
Projects¶
Reference¶
v4 API:
gitlab.Gitlab.projects
GitLab API: https://docs.gitlab.com/ce/api/projects.html
Examples¶
List projects:
The API provides several filtering parameters for the listing methods:
archived: if True only archived projects will be returned
visibility: returns only projects with the specified visibility (can be public, internal or private)
search: returns project matching the given pattern
Results can also be sorted using the following parameters:
order_by: sort using the given argument. Valid values are id, name, path, created_at, updated_at and last_activity_at. The default is to sort by created_at
sort: sort order (asc or desc)
Get a single project:
Create a project:
Create a project for a user (admin only):
Create a project in a group:
Update a project:
Delete a project:
Fork a project:
Get a list of forks for the project:
Create/delete a fork relation between projects (requires admin permissions):
Get languages used in the project with percentage value:
Star/unstar a project:
Archive/unarchive a project:
Start the housekeeping job:
List the repository tree:
Get the content and metadata of a file for a commit, using a blob sha:
Get the repository archive:
Warning
Archives are entirely stored in memory unless you use the streaming feature. See the artifacts example.
Get the content of a file using the blob id:
Warning
Blobs are entirely stored in memory unless you use the streaming feature. See the artifacts example.
Get a snapshot of the repository:
Warning
Snapshots are entirely stored in memory unless you use the streaming feature. See the artifacts example.
Compare two branches, tags or commits:
Get a list of contributors for the repository:
Get a list of users for the repository:
Start the pull mirroring process (EE edition):
Import / Export¶
You can export projects from gitlab, and re-import them to create new projects or overwrite existing ones.
Reference¶
v4 API:
gitlab.v4.objects.Project.exports
gitlab.v4.objects.Project.imports
GitLab API: https://docs.gitlab.com/ce/api/project_import_export.html
Examples¶
A project export is an asynchronous operation. To retrieve the archive generated by GitLab you need to:
Create an export using the API
Wait for the export to be done
Download the result
Import the project:
Project custom attributes¶
Reference¶
v4 API:
gitlab.v4.objects.Project.customattributes
GitLab API: https://docs.gitlab.com/ce/api/custom_attributes.html
Examples¶
List custom attributes for a project:
Get a custom attribute for a project:
Set (create or update) a custom attribute for a project:
Delete a custom attribute for a project:
Search projects by custom attribute:
Project files¶
Reference¶
v4 API:
gitlab.v4.objects.Project.files
GitLab API: https://docs.gitlab.com/ce/api/repository_files.html
Examples¶
Get a file:
Create a new file:
Update a file. The entire content must be uploaded, as plain text or as base64 encoded text:
Delete a file:
Project tags¶
Reference¶
v4 API:
gitlab.v4.objects.Project.tags
GitLab API: https://docs.gitlab.com/ce/api/tags.html
Examples¶
List the project tags:
Get a tag:
Create a tag:
Set or update the release note for a tag:
Delete a tag:
Project snippets¶
The snippet visibility can be defined using the following constants:
gitlab.VISIBILITY_PRIVATE
gitlab.VISIBILITY_INTERNAL
gitlab.VISIBILITY_PUBLIC
Reference¶
v4 API:
gitlab.v4.objects.Project.files
GitLab API: https://docs.gitlab.com/ce/api/project_snippets.html
Examples¶
List the project snippets:
Get a snippet:
Get the content of a snippet:
Warning
The snippet content is entirely stored in memory unless you use the streaming feature. See the artifacts example.
Create a snippet:
Update a snippet:
Delete a snippet:
Get user agent detail (admin only):
Project members¶
Reference¶
v4 API:
gitlab.v4.objects.Project.members
GitLab API: https://docs.gitlab.com/ce/api/members.html
Examples¶
List the project members:
List the project members recursively (including inherited members through ancestor groups):
Search project members matching a query string:
Get a single project member:
Add a project member:
Modify a project member (change the access level):
Remove a member from the project team:
Share/unshare the project with a group:
Project hooks¶
Reference¶
v4 API:
gitlab.v4.objects.Project.hooks
GitLab API: https://docs.gitlab.com/ce/api/projects.html#hooks
Examples¶
List the project hooks:
Get a project hook:
Create a project hook:
Update a project hook:
Delete a project hook:
Project Services¶
Reference¶
v4 API:
gitlab.v4.objects.Project.services
GitLab API: https://docs.gitlab.com/ce/api/services.html
Examples¶
Get a service:
List the code names of available services (doesn’t return objects):
Configure and enable a service:
Disable a service:
File uploads¶
Reference¶
Examples¶
Upload a file into a project using a filesystem path:
Upload a file into a project without a filesystem path:
Upload a file and comment on an issue using the uploaded file’s markdown:
Upload a file and comment on an issue while using custom markdown to reference the uploaded file:
Project push rules¶
Reference¶
v4 API:
gitlab.v4.objects.Project.pushrules
GitLab API: https://docs.gitlab.com/ee/api/projects.html#push-rules
Examples¶
Create project push rules (at least one rule is necessary):
Get project push rules (returns None is there are no push rules):
Edit project push rules:
Delete project push rules:
Project releases¶
Reference¶
v4 API:
gitlab.v4.objects.Project.releases
Gitlab API: https://docs.gitlab.com/ee/api/releases/index.html
Examples¶
Get a list of releases from a project:
Get a single release:
Create a release for a project tag:
Delete a release:
Project protected tags¶
Reference¶
v4 API:
gitlab.v4.objects.Project.protectedtags
GitLab API: https://docs.gitlab.com/ce/api/protected_tags.html
Examples¶
Get a list of protected tags from a project:
Get a single protected tag or wildcard protected tag:
Protect a single repository tag or several project repository tags using a wildcard protected tag:
Unprotect the given protected tag or wildcard protected tag.: