Download the Conan package manager to your local development environment by following
Download the Conan package manager to your local development environment by
the instructions at [conan.io](https://conan.io/downloads.html).
following the instructions at [conan.io](https://conan.io/downloads.html).
When installation is complete, verify you can use Conan in your terminal by running:
When installation is complete, verify you can use Conan in your terminal by
running:
```shell
```shell
conan --version
conan --version
...
@@ -42,15 +46,16 @@ Conan version 1.20.5
...
@@ -42,15 +46,16 @@ Conan version 1.20.5
### Install CMake
### Install CMake
When you develop with C++ and Conan, you have a range of compilers to choose from.
When you develop with C++ and Conan, you can select from many available
This example uses the CMake compiler.
compilers. This example uses the CMake compiler.
To install CMake:
To install CMake:
- For Mac, use [homebrew](https://brew.sh/) and run `brew install cmake`.
- For Mac, use [homebrew](https://brew.sh/) and run `brew install cmake`.
- For other operating systems, follow the instructions at [cmake.org](https://cmake.org/install/).
- For other operating systems, follow the instructions at [cmake.org](https://cmake.org/install/).
When installation is complete, verify you can use CMake in your terminal by running:
When installation is complete, verify you can use CMake in your terminal by
running:
```shell
```shell
cmake --version
cmake --version
...
@@ -60,8 +65,8 @@ The CMake version is printed in the output.
...
@@ -60,8 +65,8 @@ The CMake version is printed in the output.
### Create a project
### Create a project
To test the Package Registry, you need a C++ project. If you don't already have one, you can clone the
To test the Package Registry, you need a C++ project. If you don't already have
Conan [hello world starter project](https://github.com/conan-io/hello).
one, you can clone the Conan [hello world starter project](https://github.com/conan-io/hello).
### Build a package
### Build a package
...
@@ -74,22 +79,26 @@ To build a package:
...
@@ -74,22 +79,26 @@ To build a package:
conan new Hello/0.1 -t
conan new Hello/0.1 -t
```
```
1. Create a package for the recipe by running `conan create` with the Conan user and channel:
1. Create a package for the recipe by running `conan create` with the Conan user
and channel:
```shell
```shell
conan create . mycompany/beta
conan create . mycompany/beta
```
```
NOTE: **Note:**
NOTE: **Note:**
If you use an [instance remote](#add-a-remote-for-your-instance), you must follow a specific [naming convention](#package-recipe-naming-convention-for-instance-remotes).
If you use an [instance remote](#add-a-remote-for-your-instance), you must
follow a specific [naming convention](#package-recipe-naming-convention-for-instance-remotes).
A package with the recipe `Hello/0.1@mycompany/beta` is created.
A package with the recipe `Hello/0.1@mycompany/beta` is created.
For more details on creating and managing Conan packages, see the [Conan docs](https://docs.conan.io/en/latest/creating_packages.html).
For more details about creating and managing Conan packages, see the
| `gitlab-org/gitlab-ce` | `my-package/1.0.0@foo/stable` | No |
| `gitlab-org/gitlab-ce` | `my-package/1.0.0@foo/stable` | No |
[Project remotes](#add-a-remote-for-your-project) have a more flexible naming convention.
[Project remotes](#add-a-remote-for-your-project) have a more flexible naming
convention.
## Authenticate to the Package Registry
## Authenticate to the Package Registry
To authenticate to the Package Registry, you need either a personal access token or deploy token.
To authenticate to the Package Registry, you need either a personal access token
or deploy token.
- If you use a [personal access token](../../../user/profile/personal_access_tokens.md), set the scope to `api`.
- If you use a [personal access token](../../../user/profile/personal_access_tokens.md),
- If you use a [deploy token](../../project/deploy_tokens/index.md), set the scope to `read_package_registry`, `write_package_registry`, or both.
set the scope to `api`.
- If you use a [deploy token](../../project/deploy_tokens/index.md), set the
scope to `read_package_registry`, `write_package_registry`, or both.
### Add your credentials to the GitLab remote
### Add your credentials to the GitLab remote
Associate your token with the GitLab remote, so that you don't have to explicitly
Associate your token with the GitLab remote, so that you don't have to
add a token to every Conan command.
explicitly add a token to every Conan command.
Prerequisites:
Prerequisites:
- You must have an authentication token.
- You must have an authentication token.
- The Conan remote [must be set](#add-the-package-registry-as-a-conan-remote).
- The Conan remote [must be configured](#add-the-package-registry-as-a-conan-remote).
In a terminal, run this command. In this example, the remote name is `gitlab`. Use the name of your remote.
In a terminal, run this command. In this example, the remote name is `gitlab`.
Use the name of your remote.
```shell
```shell
conan user <gitlab_username or deploy_token_username> -r gitlab -p <personal_access_token or deploy_token>
conan user <gitlab_username or deploy_token_username> -r gitlab -p <personal_access_token or deploy_token>
```
```
Now when you run commands with `--remote=gitlab`, your username and password are automatically included in the requests.
Now when you run commands with `--remote=gitlab`, your username and password are
included in the requests.
Alternately, you can explicitly include your credentials in any given command. For example:
Alternatively, you can explicitly include your credentials in any given command.
For example:
```shell
```shell
CONAN_LOGIN_USERNAME=<gitlab_username or deploy_token_username> CONAN_PASSWORD=<personal_access_token or deploy_token> conan upload Hello/0.1@mycompany/beta --all--remote=gitlab
CONAN_LOGIN_USERNAME=<gitlab_username or deploy_token_username> CONAN_PASSWORD=<personal_access_token or deploy_token> conan upload Hello/0.1@mycompany/beta --all--remote=gitlab
```
```
NOTE: **Note:**
NOTE: **Note:**
Your authentication with GitLab expires on a regular basis,
Because your authentication with GitLab expires on a regular basis, you may
so occasionally you may need to re-enter your personal access token.
occasionally need to re-enter your personal access token.
### Set a default remote for your project (optional)
### Set a default remote for your project (optional)
If you want to interact with the GitLab Package Registry without having to specify a remote,
If you want to interact with the GitLab Package Registry without having to
you can tell Conan to always use the Package Registry for your packages.
specify a remote, you can tell Conan to always use the Package Registry for your