Conan Artifact Repository
About 579 wordsAbout 2 min
Conan Artifact Repository is used to store and distribute C/C++ packages. It supports uploading, managing and installing various C/C++ third-party libraries and tools.
Prerequisites
Local Development
Add a Remote and Login
<REMOTE_NAME> is your chosen name for the remote, <REPO_URL> is the URL of your repository.
conan remote add <REMOTE_NAME> <REPO_URL>
conan remote login -p <YOUR_TOKEN> <REMOTE_NAME> cnbPull Artifacts
conan download <PACKAGE_NAME> -r <REMOTE_NAME>Build and Push Artifacts
conan create . --user=<USER> --channel=<CHANNEL>
conan upload <PACKAGE_NAME> -r <REMOTE_NAME>Cloud Native Build
Cloud Native Build supports two methods for token usage, see [Using Tokens in Cloud Native Build and Workspaces] (./intro.md#using-tokens-in-cloud-native-build-and-cloud-native-development).
Configure Credentials, Pull and Push
The following example uses CNB_TOKEN (recommended) and combines credential configuration, pull, and push into a single pipeline. To use secret repository files, see [Using Tokens in Cloud Native Build] (./intro.md#using-tokens-in-cloud-native-build-and-cloud-native-development).
main:
push:
- docker:
image: docker.cnb.cool/examples/language/gcc-13.4
stages:
- name: Configure Conan remote credentials
script:
- conan remote add cnb-conan-repo https://conan.cnb.cool/cnb/conan-repo/-/packages/
- conan remote login -p ${CNB_TOKEN} cnb-conan-repo ${CNB_TOKEN_USER_NAME}
- name: Build Conan package
script: conan create . --user=test-user --channel=test-channel
- name: Upload Conan package
script: conan upload my-project/1.0.0@test-user/test-channel -r cnb-conan-repomain:
push:
- docker:
image: docker.cnb.cool/examples/language/gcc-13.4
stages:
- name: Configure Conan remote credentials
script:
- conan remote add cnb-conan-repo https://conan.cnb.cool/cnb/conan-repo/-/packages/
- conan remote login -p ${CNB_TOKEN} cnb-conan-repo ${CNB_TOKEN_USER_NAME}
- name: Download Conan package
script: conan download zlib/1.3.1 -r cnb-conan-repoYou can also combine pull and push in a single pipeline.
Workspaces
Prerequisites
Add the following configuration to your .cnb.yml file:
$:
vscode:
- docker:
image: docker.cnb.cool/examples/language/gcc-13.4
services:
- vscode
- docker
imports:
- <SECRET_REPO_URL>Add a Remote and Login
Using the built-in CNB_TOKEN (recommended):
conan remote add cnb-conan-repo https://conan.cnb.cool/cnb/conan-repo/-/packages/
conan remote login -p ${CNB_TOKEN} cnb-conan-repo ${CNB_TOKEN_USER_NAME}Pull Artifacts
conan download <PACKAGE_NAME> -r <REMOTE_NAME>Build and Push Artifacts
conan create . --user=<USER> --channel=<CHANNEL>
conan upload <PACKAGE_NAME> -r <REMOTE_NAME>FAQ
Q: Why can't I upload packages to the CNB Conan repository using Conan 1.x?
A: The legacy protocol of Conan 1.x is not supported. If you need to upload using Conan 1.x, enable revisions first by running export CONAN_REVISIONS_ENABLED=True, then try uploading again.
Q: Why do I get a 409 error when uploading?
A: Currently only a single recipe revision and a single package revision per version are retained. Pushing a different revision will be treated as an overwrite operation. Set your repository's overwrite policy to "Allow Overwrites", or change the package version and try again.
Q: Why do I get a 400 error when uploading?
A: This usually means the package name doesn't conform to Conan 2 naming conventions. Please verify and retry.
More Information
For more Conan usage, please refer to the official documentation.