2020-07-23 11:09:28 -04:00
---
stage: Package
group: Package
2020-11-26 01:09:20 -05:00
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2020-07-23 11:09:28 -04:00
---
2021-04-13 17:11:25 -04:00
# Store all of your packages in one GitLab project **(FREE)**
2019-12-20 13:07:53 -05:00
2020-12-16 19:09:53 -05:00
You can store all of your packages in one project's Package Registry. Rather than using
a GitLab repository to store code, you can use the repository to store all your packages.
Then you can configure your remote repositories to point to the project in GitLab.
2019-12-20 13:07:53 -05:00
2020-12-16 19:09:53 -05:00
You might want to do this because:
2019-12-20 13:07:53 -05:00
2020-12-16 19:09:53 -05:00
- You want to publish your packages in GitLab, but to a different project from where your code is stored.
2021-02-12 22:08:45 -05:00
- You want to group packages together in one project. For example, you might want to put all npm packages,
2020-12-16 19:09:53 -05:00
or all packages for a specific department, or all private packages in the same project.
- When you install packages for other projects, you want to use one remote.
- You want to migrate your packages from a third-party package registry to a single place in GitLab and do not
want to worry about setting up separate projects for each package.
- You want to have your CI/CD pipelines build all of your packages to one project, so the person responsible for
validating packages can manage them all in one place.
2019-12-20 13:07:53 -05:00
## Example walkthrough
2020-12-16 19:09:53 -05:00
No functionality is specific to this feature. Instead, we're taking advantage of the functionality
of each package management system to publish different package types to the same place.
2019-12-20 13:07:53 -05:00
2020-12-16 19:09:53 -05:00
- < i class = "fa fa-youtube-play youtube" aria-hidden = "true" ></ i >
2021-02-12 22:08:45 -05:00
Watch a video of how to add Maven, npm, and Conan packages to [the same project ](https://youtu.be/ui2nNBwN35c ).
2020-12-16 19:09:53 -05:00
- [View an example project ](https://gitlab.com/sabrams/my-package-registry/-/packages ).
2019-12-20 13:07:53 -05:00
2020-12-16 19:09:53 -05:00
## Store different package types in one GitLab project
2019-12-20 13:07:53 -05:00
2020-12-16 19:09:53 -05:00
Let's take a look at how you might create a public place to hold all of your public packages.
2019-12-20 13:07:53 -05:00
2021-06-10 11:10:14 -04:00
1. Create a new project in GitLab. The project doesn't require any code or content.
1. On the left sidebar, select **Project information** , and note the project ID.
2020-12-16 19:09:53 -05:00
1. Create an access token. All package types in the Package Registry are accessible by using
[GitLab personal access tokens ](../../profile/personal_access_tokens.md ).
If you're using CI/CD, you can use CI job tokens (`CI_JOB_TOKEN`) to authenticate.
1. Configure your local project and publish the package.
2019-12-20 13:07:53 -05:00
2020-12-16 19:09:53 -05:00
You can upload all types of packages to the same project, or
split things up based on package type or package visibility level.
2019-12-20 13:07:53 -05:00
2021-02-12 22:08:45 -05:00
### npm
2019-12-20 13:07:53 -05:00
2021-02-12 22:08:45 -05:00
If you're using npm, create an `.npmrc` file. Add the appropriate URL for publishing
2020-12-16 19:09:53 -05:00
packages to your project. Finally, add a section to your `package.json` file.
2019-12-20 13:07:53 -05:00
2020-12-16 19:09:53 -05:00
Follow the instructions in the
2021-02-12 22:08:45 -05:00
[GitLab Package Registry npm documentation ](../npm_registry/index.md#authenticate-to-the-package-registry ). After
you do this, you can publish your npm package to your project using `npm publish` , as described in the
2020-12-16 19:09:53 -05:00
[publishing packages ](../npm_registry/index.md#publish-an-npm-package ) section.
2019-12-20 13:07:53 -05:00
2020-12-16 19:09:53 -05:00
### Maven
2019-12-20 13:07:53 -05:00
2020-12-16 19:09:53 -05:00
If you are using Maven, you update your `pom.xml` file with distribution sections. These updates include the
2019-12-20 13:07:53 -05:00
appropriate URL for your project, as described in the [GitLab Maven Repository documentation ](../maven_repository/index.md#project-level-maven-endpoint ).
2020-10-27 23:08:41 -04:00
Then, you need to add a `settings.xml` file and [include your access token ](../maven_repository/index.md#authenticate-with-a-personal-access-token-in-maven ).
2020-12-16 19:09:53 -05:00
Now you can [publish Maven packages ](../maven_repository/index.md#publish-a-package ) to your project.
### Conan
2019-12-20 13:07:53 -05:00
2020-12-16 19:09:53 -05:00
For Conan, you need to add GitLab as a Conan registry remote. Follow the instructions in the
[GitLab Conan Repository docs ](../conan_repository/index.md#add-the-package-registry-as-a-conan-remote ).
Then, create your package using the plus-separated (`+`) project path as your Conan user. For example,
if your project is located at `https://gitlab.com/foo/bar/my-proj` ,
[create your Conan package ](../conan_repository/index.md ) using `conan create . foo+bar+my-proj/channel` .
2021-01-11 19:10:42 -05:00
`channel` is your package channel (such as `stable` or `beta` ).
2019-12-20 13:07:53 -05:00
2020-12-16 19:09:53 -05:00
After you create your package, you're ready to [publish your package ](../conan_repository/index.md#publish-a-conan-package ),
depending on your final package recipe. For example:
2019-12-20 13:07:53 -05:00
2020-01-30 10:09:15 -05:00
```shell
2019-12-20 13:07:53 -05:00
CONAN_LOGIN_USERNAME=< gitlab-username > CONAN_PASSWORD=< personal_access_token > conan upload MyPackage/1.0.0@foo+bar+my-proj/channel --all --remote=gitlab
```
2020-09-14 14:09:48 -04:00
2021-03-02 16:11:07 -05:00
### Composer
You can't publish a Composer package outside of its project. An [issue ](https://gitlab.com/gitlab-org/gitlab/-/issues/250633 )
exists to implement functionality that allows you to publish such packages to other projects.
2020-12-16 19:09:53 -05:00
### All other package types
2020-09-14 14:09:48 -04:00
2020-12-16 19:09:53 -05:00
[All package types supported by GitLab ](../index.md ) can be published in
the same GitLab project. In previous releases, not all package types could
be published in the same project.