Phong thủy

Conan packages in the Package Registry – GitLab Documentation

Dưới đây là danh sách Doc conan đầy đủ nhất được tổng hợp bởi chúng tôi

  • Add the Package Registry as a Conan remote
    • Add a remote for your project
    • Add a remote for your instance
      • Package recipe naming convention for instance remotes
  • Authenticate to the Package Registry
    • Add your credentials to the GitLab remote
    • Set a default remote for your project (optional)
  • Publish a Conan package
  • Publish a Conan package by using CI/CD
    • Re-publishing a package with the same recipe
  • Install a Conan package
  • Remove a Conan package
  • Search for Conan packages in the Package Registry
  • Fetch Conan package information from the Package Registry
  • Supported CLI commands
  • Troubleshooting
    • Make output verbose
    • SSL Errors

Publish Conan packages in your project’s Package Registry. Then install the packages whenever you need to use them as a dependency.

To publish Conan packages to the Package Registry, add the Package Registry as a remote and authenticate with it.

Then you can run conan commands and publish your package to the Package Registry.

For documentation of the specific API endpoints that the Conan package manager client uses, see the Conan API documentation.

Learn how to build a Conan package.

Add the Package Registry as a Conan remote

To run conan commands, you must add the Package Registry as a Conan remote for your project or instance. Then you can publish packages to and install packages from the Package Registry.

Add a remote for your project

Set a remote so you can work with packages in a project without having to specify the remote name in every command.

When you set a remote for a project, there are no restrictions to your package names. However, your commands must include the full recipe, including the user and channel, for example, package_name/version@user/channel.

To add the remote:

  1. In your terminal, run this command:

  2. Use the remote by adding -remote=gitlab to the end of your Conan command.

    For example:

Add a remote for your instance

Use a single remote to access packages across your entire GitLab instance.

However, when using this remote, you must follow these package naming restrictions.

To add the remote:

  1. In your terminal, run this command:

  2. Use the remote by adding -remote=gitlab to the end of your Conan command.

    For example:

Package recipe naming convention for instance remotes

The standard Conan recipe convention is package_name/version@user/channel, but if you’re using an instance remote, the recipe user must be the plus sign (+) separated project path.

Example recipe names:

ProjectPackageSupportedfoo/barmy-package/1.0.0@foo+bar/stableYesfoo/bar-baz/buzmy-package/1.0.0@foo+bar-baz+buz/stableYesgitlab-org/gitlab-cemy-package/1.0.0@gitlab-org+gitlab-ce/stableYesgitlab-org/gitlab-cemy-package/1.0.0@foo/stableNo

Project remotes have a more flexible naming convention.

Authenticate to the Package Registry

GitLab requires authentication to upload packages, and to install packages from private and internal projects. (You can, however, install packages from public projects without authentication.)

To authenticate to the Package Registry, you need one of the following:

  • A personal access token with the scope set to api.
  • A deploy token with the scope set to read_package_registry, write_package_registry, or both.
  • A CI job token.

Add your credentials to the GitLab remote

Associate your token with the GitLab remote, so that you don’t have to explicitly add a token to every Conan command.

Prerequisites:

  • You must have an authentication token.
  • The Conan remote must be configured.

In a terminal, run this command. In this example, the remote name is gitlab. Use the name of your remote.

Now when you run commands with -remote=gitlab, your username and password are included in the requests.

Set a default remote for your project (optional)

If you want to interact with the GitLab Package Registry without having to specify a remote, you can tell Conan to always use the Package Registry for your packages.

In a terminal, run this command:

If you don’t set a default user or remote, you can still include the user and remote in your commands:

Publish a Conan package

Publish a Conan package to the Package Registry, so that anyone who can access the project can use the package as a dependency.

Prerequisites:

  • The Conan remote must be configured.
  • Authentication with the Package Registry must be configured.
  • A local Conan package must exist.
    • For an instance remote, the package must meet the naming convention.
  • You must have the project ID, which is on the project’s homepage.

To publish the package, use the conan upload command:

Publish a Conan package by using CI/CD

To work with Conan commands in GitLab CI/CD, you can use CI_JOB_TOKEN in place of the personal access token in your commands.

You can provide the CONAN_LOGIN_USERNAME and CONAN_PASSWORD with each Conan command in your .gitlab-ci.yml file. For example:

Additional Conan images to use as the basis of your CI file are available in the Conan docs.

Re-publishing a package with the same recipe

When you publish a package that has the same recipe (package-name/version@user/channel) as an existing package, the duplicate files are uploaded successfully and are accessible through the UI. However, when the package is installed, only the most recently-published package is returned.

Install a Conan package

Install a Conan package from the Package Registry so you can use it as a dependency. You can install a package from the scope of your instance or your project. If multiple packages have the same recipe, when you install a package, the most recently-published package is retrieved.

Conan packages are often installed as dependencies by using the conanfile.txt file.

Prerequisites:

  • The Conan remote must be configured.
  • For private and internal projects, you must configure Authentication with the Package Registry.
  1. In the project where you want to install the package as a dependency, open conanfile.txt. Or, in the root of your project, create a file called conanfile.txt.

  2. Add the Conan recipe to the [requires] section of the file:

  3. At the root of your project, create a build directory and change to that directory:

  4. Install the dependencies listed in conanfile.txt:

Remove a Conan package

There are two ways to remove a Conan package from the GitLab Package Registry.

  • From the command line, using the Conan client:

    You must explicitly include the remote in this command, otherwise the package is removed only from your local system cache.

  • From the GitLab user interface:

    Go to your project’s Packages and registries > Package Registry. Remove the package by selecting Remove repository ().

Search for Conan packages in the Package Registry

To search by full or partial package name, or by exact recipe, run the conan search command.

  • To search for all packages with a specific package name:

  • To search for a partial name, like all packages starting with He:

The scope of your search includes all projects you have permission to access. This includes your private projects as well as all public projects.

Fetch Conan package information from the Package Registry

The conan info command returns information about a package:

Supported CLI commands

The GitLab Conan repository supports the following Conan CLI commands:

  • conan upload: Upload your recipe and package files to the Package Registry.
  • conan install: Install a Conan package from the Package Registry, which includes using the conanfile.txt file.
  • conan search: Search the Package Registry for public packages, and private packages you have permission to view.
  • conan info: View the information on a given package from the Package Registry.
  • conan remove: Delete the package from the Package Registry.

Troubleshooting

Make output verbose

For more verbose output when troubleshooting a Conan issue:

You can find more logging tips in the Conan documentation.

SSL Errors

If you are using a self-signed certificate, there are two methods to manage SSL errors with Conan:

  • Use the conan remote command to disable the SSL verification.
  • Append your server crt file to the cacert.pem file.

Read more about this in the Conan Documentation.

Rate this post
Back to top button