Last active
January 22, 2020 12:59
-
-
Save rodrigosiviero/523e8ed67b35191e6edc6913e57e23bf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import gitlab | |
| #Creates a Gitlab Connection object | |
| gl = gitlab.Gitlab('https://gitlab.example.com/gitlab', private_token=os.environ['your_token']) | |
| #Creates a function to get the project internal ID from the CI. | |
| def get_project(project_id): | |
| return gl.projects.get(project_id) | |
| #Creates the create_release function | |
| def create_release(project_id, version): | |
| #Gets the Project ID to be used later and stores to a variable. | |
| project = get_project(project_id) | |
| #defines the information to go to the release. | |
| release_name = "My initial release" | |
| description = "My awesome release notes" | |
| #Creates the new release. | |
| release = project.releases.create({'name': release_name, 'tag_name': version, 'description': description }) | |
| print(f'Created a new release with the tag: {tag_name} and project ID is: {project_id}') | |
| #Creates the release! | |
| create_release("24","v1.0") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment