Protected packages
{{< details >}}
- Tier: Free, Premium, Ultimate
- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
{{< /details >}}
{{< history >}}
-
Introduced in GitLab 16.5 with a flag named
packages_protected_packages
. Disabled by default. This feature is an experiment. - The protection rule setting Push protected up to access level renamed to Minimum access level for push in GitLab 17.1.
- Enabled on GitLab.com in GitLab 17.5.
-
Generally available in GitLab 17.6. Feature flag
packages_protected_packages
removed. - Conan protected packages introduced in GitLab 17.6 with a flag named
packages_protected_packages_conan
. Disabled by default. This feature is an experiment. - Maven protected packages introduced in GitLab 17.9 with a flag named
packages_protected_packages_maven
. Disabled by default. This feature is an experiment. -
Introduced in GitLab 17.10 with a flag named
packages_protected_packages_delete
. Disabled by default. This feature is an experiment. -
Generally available in GitLab 17.11. Feature flag
packages_protected_packages_maven
removed. -
Generally available in GitLab 17.11. Feature flag
packages_protected_packages_conan
removed.
{{< /history >}}
By default, any user with at least the Developer role can create, edit, and delete packages. Add a package protection rule to restrict which users can make changes to your packages.
GitLab supports package protection for npm, PyPI, Maven, and Conan packages, but epic 5574 proposes to add additional features and package formats.
When a package is protected, the default behavior enforces these restrictions on the package:
Action | Minimum role or token |
---|---|
Protect a package | At least the Maintainer role. |
Push a new package | At least the role set in Minimum access level for push. |
Push a new package with a deploy token | Any valid deploy token, only if the pushed package is not matched by a protection rule. Protected packages cannot be pushed with a deploy token. |
Delete a package | At least the role set in Minimum access level for delete. |
Protect a package
{{< history >}}
- Introduced in GitLab 16.9.
{{< /history >}}
Prerequisites:
- You must have at least the Maintainer role.
To protect a package:
- On the left sidebar, select Search or go to and find your project.
- Select Settings > Packages and registries.
- Expand Package registry.
- Under Protected packages, select Add protection rule.
- Complete the fields:
-
Name pattern is a package name pattern you want to protect. The pattern can include a wildcard (
*
). - Package type is the type of package to protect.
- Minimum access level for push is the minimum role required to push a package matching the name pattern.
- Minimum access level for delete is the minimum role required to delete a package matching the name pattern.
-
Name pattern is a package name pattern you want to protect. The pattern can include a wildcard (
- Select Protect.
The package protection rule is created, and appears in the settings.
Protecting multiple packages
You can use a wildcard to protect multiple packages with the same package protection rule. For example, you can protect all the temporary packages built during a CI/CD pipeline.
The following table contains examples of package protection rules that match multiple packages:
Package name pattern with wildcard | Matching packages |
---|---|
@group/package-*
|
@group/package-prod , @group/package-prod-sha123456789
|
@group/*package
|
@group/package , @group/prod-package , @group/prod-sha123456789-package
|
@group/*package*
|
@group/package , @group/prod-sha123456789-package-v1
|
It’s possible to apply several protection rules to the same package. If at least one protection rule applies to the package, the package is protected.
Delete a package protection rule and unprotect a package
{{< history >}}
- Introduced in GitLab 16.10.
{{< /history >}}
Prerequisites:
- You must have at least the Maintainer role.
To unprotect a package:
- On the left sidebar, select Search or go to and find your project.
- Select Settings > Packages and registries.
- Expand Package registry.
- Under Protected packages, next to the protection rule you want to delete, select Delete ({{< icon name=”remove” >}}).
- On the confirmation dialog, select Delete.
The package protection rule is deleted, and does not appear in the settings.