Code Stream provides a way to trigger a pipeline if a code change occurs in your GitHub, GitLab, or Bitbucket repository. The Git trigger uses a Git endpoint on the branch of the repository that you want to monitor. Code Stream connects to the Git endpoint through a webhook.
To define a Git endpoint in
Code Stream, you select a project and enter the branch of the Git repository where the endpoint is located. The project groups the pipeline with the endpoint and other related objects. When you choose the project in your webhook definition, you select the endpoint and pipeline to trigger.
You can create multiple webhooks for different branches by using the same Git endpoint and providing different values for the branch name in the webhook configuration page. To create another webhook for another branch in the same Git repository, you don't need to clone the Git endpoint multiple times for multiple branches. Instead, you provide the branch name in the webhook, which allows you to reuse the Git endpoint. If the branch in the Git webhook is the same as the branch in the endpoint, you don't need to provide branch name in the Git webhook page.
Prerequisites
- Verify that you can access the GitHub, GitLab, or Bitbucket repository to which you plan to connect.
- Verify that you are a member of a project in Code Stream. If you are not, ask a Code Stream administrator to add you as a member of a project. See How do I add a project in Code Stream.
Procedure
- Define a Git endpoint.
- Click .
- Select a project, and for the endpoint type select Git. Then, enter a name and description.
- If this endpoint is a business-critical component in your infrastructure, enable Mark as restricted.
When you use a restricted endpoint in a pipeline, an administrator can run the pipeline and must approve the pipeline execution. If an endpoint or variable is marked as restricted, and a non-administrative user triggers the pipeline, the pipeline pauses at that task, and waits for an administrator to resume it.
A Project administrator can start a pipeline that includes restricted endpoints or variables if these resources are in the project where the user is a Project administrator.
When a user who is not an administrator attempts to run a pipeline that includes a restricted resource, the pipeline stops at the task that uses the restricted resource. Then, an administrator must resume the pipeline.
For more information about restricted resources, and custom roles that include the permission called
Manage Restricted Pipelines, see:
- Select one of the supported Git server types.
- Enter the URL for the repository with the API gateway for the server in the path. For example:
For GitHub, enter:
https://api.github.com/vmware-example/repo-example
For BitBucket, enter:
https://api.bitbucket.org/{user}/{repo name} or
http(s)://{bitbucket-enterprise-server}/rest/api/1.0/users/{username}/repos/{repo name}
- Enter the branch in the repository where the endpoint is located.
- Select the Authentication type and enter the user name for GitHub, GitLab, or BitBucket. Then enter the private token that goes with the user name.
- Password. To create a webhook later, you must enter the private token for the password. Webhooks for Git do not support endpoints created using basic authentication.
Use secret variables to hide and encrypt sensitive information. Use restricted variable for strings, passwords, and URLs that must be hidden and encrypted, and to restrict use in executions. For example, use a secret variable for a password or URL. You can use secret and restricted variables in any type of task in your pipeline.
- Private token. This token is Git-specific and provides access to a specific action. See https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html. You can also create a variable for the private token.
- Click Validate, and verify that the endpoint connects to Code Stream.
If it does not connect, correct any errors, then click
Create.
What to do next
To learn more, review the other sections. See How do I use the Git trigger in Code Stream to run a pipeline.