Skip to content
代码片段 群组 项目
提交 113e261f 编辑于 作者: Russell Dickenson's avatar Russell Dickenson 提交者: Kati Paizee
浏览文件

Edit deploy token tasks to adhere to CTRT convention

上级 084bc132
No related branches found
No related tags found
无相关合并请求
...@@ -84,7 +84,7 @@ You can authenticate using: ...@@ -84,7 +84,7 @@ You can authenticate using:
- Your GitLab username and password. - Your GitLab username and password.
- A [personal access token](../../../user/profile/personal_access_tokens.md) with the scope set to `read_registry` and `write_registry`. - A [personal access token](../../../user/profile/personal_access_tokens.md) with the scope set to `read_registry` and `write_registry`.
- A [group deploy token](../../../user/project/deploy_tokens/index.md#group-deploy-token) with the scope set to `read_registry` and `write_registry`. - A [group deploy token](../../../user/project/deploy_tokens/index.md) with the scope set to `read_registry` and `write_registry`.
Users accessing the Dependency Proxy with a personal access token or username and password must Users accessing the Dependency Proxy with a personal access token or username and password must
have at least the Guest role for the group they pull images from. have at least the Guest role for the group they pull images from.
......
...@@ -53,7 +53,7 @@ For most package types, the following credential types are valid: ...@@ -53,7 +53,7 @@ For most package types, the following credential types are valid:
- [Project deploy token](../../project/deploy_tokens/index.md): - [Project deploy token](../../project/deploy_tokens/index.md):
allows access to all packages in a project. Good for granting and revoking project access to many allows access to all packages in a project. Good for granting and revoking project access to many
users. users.
- [Group deploy token](../../project/deploy_tokens/index.md#group-deploy-token): - [Group deploy token](../../project/deploy_tokens/index.md):
allows access to all packages in a group and its subgroups. Good for granting and revoking access allows access to all packages in a group and its subgroups. Good for granting and revoking access
to a large number of packages to sets of users. to a large number of packages to sets of users.
- [Job token](../../../ci/jobs/ci_job_token.md): - [Job token](../../../ci/jobs/ci_job_token.md):
......
doc/user/project/deploy_tokens/img/deploy_tokens_ui.png

34.5 KB

...@@ -83,158 +83,150 @@ Deploy tokens can't be used with the GitLab public API. However, you can use dep ...@@ -83,158 +83,150 @@ Deploy tokens can't be used with the GitLab public API. However, you can use dep
endpoints, such as those from the Package Registry. For more information, see endpoints, such as those from the Package Registry. For more information, see
[Authenticate with the registry](../../packages/package_registry/index.md#authenticate-with-the-registry). [Authenticate with the registry](../../packages/package_registry/index.md#authenticate-with-the-registry).
## Creating a Deploy token ## Create a deploy token
You can create as many deploy tokens as you need from the settings of your Create a deploy token to automate deployment tasks that can run independently of a user account.
project. Alternatively, you can also create [group-scoped deploy tokens](#group-deploy-token).
Prerequisites:
- You must have at least the Maintainer role for the project or group.
1. Sign in to your GitLab account.
1. On the top bar, select **Main menu**, and: 1. On the top bar, select **Main menu**, and:
- For a project, select ***Projects** and find your project. - For a project deploy token, select **Projects** and find your project.
- For a group, select **Groups** and find your group. - For a group deploy token, select **Groups** and find your group.
1. On the left sidebar, select **Settings > Repository**. 1. On the left sidebar, select **Settings > Repository**.
1. Expand **Deploy tokens**. 1. Expand **Deploy tokens**.
1. Choose a name, and optionally, an expiration date and username for the token. 1. Complete the fields, and select the desired [scopes](#scope).
1. Choose the [desired scopes](#scope).
1. Select **Create deploy token**. 1. Select **Create deploy token**.
Save the deploy token somewhere safe. After you leave or refresh Record the deploy token's values. After you leave or refresh the page, **you cannot access it
the page, **you can't access it again**. again**.
## Revoke a deploy token
![Personal access tokens page](img/deploy_tokens_ui.png) Revoke a token when it's no longer required.
## Revoking a deploy token Prerequisites:
- You must have at least the Maintainer role for the project or group.
To revoke a deploy token: To revoke a deploy token:
1. On the top bar, select **Main menu**, and: 1. On the top bar, select **Main menu**, and:
- For a project, select ***Projects** and find your project. - For a project deploy token, select **Projects** and find your project.
- For a group, select **Groups** and find your group. - For a group deploy token, select **Groups** and find your group.
1. On the left sidebar, select **Settings > Repository**. 1. On the left sidebar, select **Settings > Repository**.
1. Expand **Deploy tokens**. 1. Expand **Deploy tokens**.
1. In the **Active Deploy Tokens** section, by the token you want to revoke, select **Revoke**. 1. In the **Active Deploy Tokens** section, by the token you want to revoke, select **Revoke**.
## Usage ## Clone a repository
You can use a deploy token to clone a repository.
Prerequisites:
### Git clone a repository - A deploy token with the `read_repository` scope.
To download a repository using a deploy token: Example of using a deploy token to clone a repository:
1. Create a deploy token with `read_repository` as a scope. ```shell
1. Take note of your `username` and `token`. git clone https://<username>:<deploy_token>@gitlab.example.com/tanuki/awesome_project.git
1. `git clone` the project using the deploy token: ```
```shell ## Pull images from a container registry
git clone https://<username>:<deploy_token>@gitlab.example.com/tanuki/awesome_project.git
```
Replace `<username>` and `<deploy_token>` with the proper values. You can use a deploy token to pull images from a container registry.
### Read Container Registry images Prerequisites:
To read the container registry images, you must: - A deploy token with the `read_registry` scope.
1. Create a deploy token with `read_registry` as a scope. Example of using a deploy token to pull images from a container registry:
1. Take note of your `username` and `token`.
1. Sign in to the GitLab Container Registry using the deploy token:
```shell ```shell
docker login -u <username> -p <deploy_token> registry.example.com docker login -u <username> -p <deploy_token> registry.example.com
docker pull $CONTAINER_TEST_IMAGE
``` ```
Replace `<username>` and `<deploy_token>` with the proper values. You can now ## Push images to a container registry
pull images from your Container Registry.
### Push Container Registry images
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/22743) in GitLab 12.10. You can use a deploy token to push images to a container registry.
To push the container registry images, you must: Prerequisites:
1. Create a deploy token with `write_registry` as a scope. - A deploy token with the `write_registry` scope.
1. Take note of your `username` and `token`.
1. Sign in to the GitLab Container Registry using the deploy token:
```shell Example of using a deploy token to push an image to a container registry:
docker login -u <username> -p <deploy_token> registry.example.com
```
Replace `<username>` and `<deploy_token>` with the proper values. You can now ```shell
push images to your Container Registry. docker login -u <username> -p <deploy_token> registry.example.com
docker push $CONTAINER_TEST_IMAGE
```
### Read or pull packages ## Pull packages from a package registry
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/213566) in GitLab 13.0. > [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/213566) in GitLab 13.0.
To pull packages in the GitLab package registry, you must: You can use a deploy token to pull packages from a package registry.
1. Create a deploy token with `read_package_registry` as a scope. Prerequisites:
1. Take note of your `username` and `token`.
1. For the [package type of your choice](../../packages/index.md), follow the
authentication instructions for deploy tokens.
Example request publishing a NuGet package using a deploy token: - A deploy token with the `read_package_registry` scope.
```shell For the [package type of your choice](../../packages/index.md), follow the authentication
nuget source Add -Name GitLab -Source "https://gitlab.example.com/api/v4/projects/10/packages/nuget/index.json" -UserName deploy-token-username -Password 12345678asdf instructions for deploy tokens.
nuget push mypkg.nupkg -Source GitLab Example of installing a NuGet package from a GitLab registry:
```shell
nuget source Add -Name GitLab -Source "https://gitlab.example.com/api/v4/projects/10/packages/nuget/index.json" -UserName <username> -Password <deploy_token>
nuget install mypkg.nupkg
``` ```
### Push or upload packages ## Push packages to a package repository
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/213566) in GitLab 13.0. > [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/213566) in GitLab 13.0.
To upload packages in the GitLab package registry, you must: You can use a deploy token to push packages to a GitLab package registry.
1. Create a deploy token with `write_package_registry` as a scope.
1. Take note of your `username` and `token`.
1. For the [package type of your choice](../../packages/index.md), follow the
authentication instructions for deploy tokens.
### Group deploy token
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/21765) in GitLab 12.9. Prerequisites:
A deploy token created at the group level can be used across all projects that - A deploy token with the `write_package_registry` scope.
belong either to the specific group or to one of its subgroups.
<i class="fa fa-youtube-play youtube" aria-hidden="true"></i> For the [package type of your choice](../../packages/index.md), follow the authentication
For an overview, see [Group Deploy Tokens](https://youtu.be/8kxTJvaD9ks). instructions for deploy tokens.
The Group deploy tokens UI is now accessible under **Settings > Repository**, Example of publishing a NuGet package to a package registry:
not **Settings > CI/CD** as indicated in the video.
To use a group deploy token: ```shell
nuget source Add -Name GitLab -Source "https://gitlab.example.com/api/v4/projects/10/packages/nuget/index.json" -UserName <username> -Password <deploy_token>
nuget push mypkg.nupkg -Source GitLab
```
1. [Create](#creating-a-deploy-token) a deploy token for a group. ## Pull images from the dependency proxy
1. Use it the same way you use a project deploy token when
[cloning a repository](#git-clone-a-repository).
The scopes applied to a group deploy token (such as `read_repository`) > [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/280586) in GitLab 14.2.
apply consistently when cloning the repository of related projects.
### Pull images from the Dependency Proxy You can use a deploy token to pull images from the dependency proxy.
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/280586) in GitLab 14.2. Prerequisites:
To pull images from the Dependency Proxy, you must: - A deploy token with `read_registry` and `write_registry` scopes.
1. Create a group deploy token with both `read_registry` and `write_registry` scopes. Follow the dependency proxy [authentication instructions](../../packages/dependency_proxy/index.md).
1. Take note of your `username` and `token`.
1. Follow the Dependency Proxy [authentication instructions](../../packages/dependency_proxy/index.md).
## Troubleshooting ## Troubleshooting
### Group deploy tokens and LFS ### Error: `api error: Repository or object not found:`
A bug When using a group deploy token to clone from LFS objects, you might get `404 Not Found` responses
[prevents Group Deploy Tokens from cloning LFS objects](https://gitlab.com/gitlab-org/gitlab/-/issues/235398). and this error message. This occurs because of a bug, documented in
If you receive `404 Not Found` errors and this error, [issue 235398](https://gitlab.com/gitlab-org/gitlab/-/issues/235398).
use a Project Deploy Token to work around the bug:
```plaintext ```plaintext
api error: Repository or object not found: api error: Repository or object not found:
https://<URL-with-token>.git/info/lfs/objects/batch https://<URL-with-token>.git/info/lfs/objects/batch
Check that it exists and that you have proper access to it Check that it exists and that you have proper access to it
``` ```
The workaround is to use a project deploy token.
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册