-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add gitlab documentation #701
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# GitLab | ||
|
||
The [GitLab](https://gitlab.com) integration allows you to manage your Platform.sh environments directly from your GitLab repository. | ||
|
||
Features supported: | ||
|
||
* Create a new environment when creating a branch or opening a pull request on GitLab. | ||
* Rebuild the environment when pushing new code to GitLab. | ||
* Delete the environment when merging a pull request. | ||
|
||
## Setup | ||
|
||
### 1. Generate a token | ||
|
||
To integrate your Platform.sh project with an existing GitLab repository, you first need to generate a token on your GitLab user profile. Simply go to your Settings page on GitLab and click `Access Tokens`. | ||
|
||
Fill the `Name` field for example with "Platform.sh Integration" and optionally set an expiration time. | ||
|
||
Give it a description and then ensure the token has the following scopes: | ||
|
||
* `api` - Access your API | ||
* `read_user` - Read user information | ||
* `read_registry` - Read Registry | ||
|
||
Copy the token and make a note of it (temporarily). | ||
|
||
Note that for the integration to work, your GitLab user needs to have permission to push code to the repository. | ||
|
||
### 2. Enable the integration | ||
|
||
Note that only `project owner` or `project admin` can manage the integrations. | ||
|
||
Open a terminal window (you need to have the Platform.sh CLI installed). Enable the GitLab integration as follows: | ||
|
||
```bash | ||
platform integration:add --type=gitlab --token=THE-TOKEN-YOU-WROTE-DOWN --base-url=https://THE-URL-OF-YOUR-GITLAB/ --gitlab-project=MY-NAMESPACE/MY-PROJECTNAME | ||
``` | ||
|
||
Optional parameters: | ||
* `--fetch-branches`: Track and deploy branches (true by default) | ||
* `--build-merge-requests`: Track and deploy merge-requests (true by default) | ||
* `--merge-requests-clone-parent-data` : should merge requests clone the data from the parent environment (true by default) | ||
|
||
### 3. Add the webhook | ||
|
||
The previous command, if succesful should output the configuration of the integration. The last element would look like: | ||
|
||
``` | ||
| hook_url | https://{region}.platform.sh/api/projects/{projectid}/integrations/{hook_id}/hook | | ||
``` | ||
|
||
Now, copy the hook URL. | ||
|
||
Go to your GitLab repository and click `Settings > Integrations` and paste the Payload URL, in the Triggers section choose | ||
`Push events`, `Tag push events` and `Merge Request events`. And click on `Add webhook`. | ||
|
||
You can now start pushing code, creating new branches or opening merge requests directly on your GitLab repository. You will see environments get automatically created and updated on the Platform.sh side. | ||
|
||
|
||
## Types of environments | ||
|
||
Environments based on GitLab **merge requests** will have the correct 'parent' environment on Platform.sh; they will be activated automatically with a copy of the parent's data (unless you have set the option `merge-requests-clone-parent-data` to false). | ||
|
||
However, environments based on (non-merge-request) **branches** cannot have parents; they will inherit directly from `master` and start inactive by default. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't add the hook automatically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe so. If we can that would be a very good thing (also for github etc.. there is a ticket for that)