Conan Artifact Repository
About 1088 wordsAbout 4 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
# Example: conan remote add cnb-conan-repo https://conan.cnb.cool/cnb/conan-repo/-/packages/
conan remote add <REMOTE_NAME> <REPO_URL>
# Example: conan remote login -p my-token cnb-conan-repo cnb
conan remote login -p <YOUR_TOKEN> <REMOTE_NAME> cnbPull Artifacts
# Example: conan download zlib/1.3.1 -r cnb-conan-repo
conan download <PACKAGE_NAME> -r <REMOTE_NAME>Build and Push Artifacts
# Create the package locally first
# Example 1: conan create .
# Example 2: conan create . --user=test-user --channel=test-channel
conan create . --user=<USER> --channel=<CHANNEL>
# Upload the package to the remote
# Example 1: conan upload my-project/1.0.0 -r cnb-conan-repo (without user and channel)
# Example 2: conan upload my-project/1.0.0@test-user/test-channel -r cnb-conan-repo (with user and channel)
conan upload <PACKAGE_NAME> -r <REMOTE_NAME>Cloud Native Build
Pull Artifacts
- Option 1: Using the built-in
CNB_TOKENenvironment variable:
master:
push:
- docker:
image: docker.cnb.cool/examples/language/gcc-13.4
stages:
- name: Configure Conan remote credentials
script:
# Example: conan remote add cnb-conan-repo https://conan.cnb.cool/cnb/conan-repo/-/packages/
- conan remote add <REMOTE_NAME> <REPO_URL>
# Example: conan remote login -p ${CNB_TOKEN} cnb-conan-repo ${CNB_TOKEN_USER_NAME}
- conan remote login -p ${CNB_TOKEN} <REMOTE_NAME> ${CNB_TOKEN_USER_NAME}
- name: Download Conan package
script:
# Example: conan download zlib/1.3.1 -r cnb-conan-repo
- conan download <PACKAGE_NAME> -r <REMOTE_NAME>- Option 2: Use the secret repository file:
master:
push:
- docker:
image: docker.cnb.cool/examples/language/gcc-13.4
import:
# Import secret repository configuration file
- <SECRET_REPO_URL>
stages:
- name: Configure Conan remote credentials
script:
- conan remote add <REMOTE_NAME> <REPO_URL>
- conan remote login -p <PASS_WORD> <REMOTE_NAME> <USER_NAME>
- name: Download Conan package
script:
- conan download <PACKAGE_NAME> -r <REMOTE_NAME>Example:
master:
push:
- docker:
image: docker.cnb.cool/examples/language/gcc-13.4
import:
- https://cnb.cool/cnb-demo/env-demo/-/blob/main/envs/env.yml
stages:
- name: Configure Conan remote credentials
script:
- conan remote add cnb-conan-repo https://conan.cnb.cool/cnb/conan-repo/-/packages/
# Import secret registry file and inject USER_NAME and PASS_WORD as environment variables
- conan remote login -p ${PASS_WORD} cnb-conan-repo ${USER_NAME}
- name: Download Conan package
script:
- conan download zlib/1.3.1 -r cnb-conan-repoBuild and Push Artifacts
- Option 1: Using the built-in
CNB_TOKENenvironment variable:
master:
push:
- docker:
image: docker.cnb.cool/examples/language/gcc-13.4
stages:
- name: Configure Conan remote credentials
script:
# Example: conan remote add cnb-conan-repo https://conan.cnb.cool/cnb/conan-repo/-/packages/
- conan remote add <REMOTE_NAME> <REPO_URL>
# Example: conan remote login -p ${CNB_TOKEN} cnb-conan-repo ${CNB_TOKEN_USER_NAME}
- conan remote login -p ${CNB_TOKEN} <REMOTE_NAME> ${CNB_TOKEN_USER_NAME}
- name: Build Conan package
script:
# Example: conan create . --user=test-user --channel=test-channel
- conan create . --user=<USER> --channel=<CHANNEL>
- name: Upload Conan package
script:
# Example: conan upload my-project/1.0.0@test-user/test-channel -r cnb-conan-repo
- conan upload <PACKAGE_NAME> -r <REMOTE_NAME>- Option 2: Use the secret repository file:
master:
push:
- docker:
image: docker.cnb.cool/examples/language/gcc-13.4
import:
# Import secret repository configuration file
- <SECRET_REPO_URL>
stages:
- name: Configure Conan remote credentials
script:
- conan remote add <REMOTE_NAME> <REPO_URL>
- conan remote login -p <PASS_WORD> <REMOTE_NAME> <USER_NAME>
- name: Build Conan package
script:
- conan create . --user=<USER> --channel=<CHANNEL>
- name: Upload Conan package
script:
- conan upload <PACKAGE_NAME> -r <REMOTE_NAME>Example:
master:
push:
- docker:
image: docker.cnb.cool/examples/language/gcc-13.4
import:
- https://cnb.cool/cnb-demo/env-demo/-/blob/main/envs/env.yml
stages:
- name: Configure Conan remote credentials
script:
- conan remote add cnb-conan-repo https://conan.cnb.cool/cnb/conan-repo/-/packages/
# The imported secret file injects USER_NAME and PASS_WORD as environment variables
- conan remote login -p ${PASS_WORD} cnb-conan-repo ${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-repoWorkspaces
Prerequisites
Add the following configuration to your .cnb.yml file:
$:
vscode:
- docker:
image: docker.cnb.cool/examples/language/gcc-13.4
services:
- vscode
- docker
# If using the secret repository file, fill in the following configuration
imports:
# Example: https://cnb.cool/cnb-demo/env-demo/-/blob/main/envs/env.yml
- <SECRET_REPO_URL>Add a Remote and Login
- Option 1: Using the built-in
CNB_TOKENenvironment variable
# <REMOTE_NAME> is your chosen name for the remote
# <REPO_URL> is the URL of your repository
# Example: conan remote add cnb-conan-repo https://conan.cnb.cool/cnb/conan-repo/-/packages/
conan remote add <REMOTE_NAME> <REPO_URL>
# Example: conan remote login -p ${CNB_TOKEN} cnb-conan-repo ${CNB_TOKEN_USER_NAME}
conan remote login -p ${CNB_TOKEN} <REMOTE_NAME> ${CNB_TOKEN_USER_NAME}- Option 2: Use the secret repository file:
# <REMOTE_NAME> is your chosen name for the remote
# <REPO_URL> is the URL of your repository
# Example: conan remote add cnb-conan-repo https://conan.cnb.cool/cnb/conan-repo/-/packages/
conan remote add <REMOTE_NAME> <REPO_URL>
# The imported secret file injects USER_NAME and PASS_WORD as environment variables
# Example: conan remote login -p ${PASS_WORD} cnb-conan-repo ${USER_NAME}
conan remote login -p ${PASS_WORD} <REMOTE_NAME> ${USER_NAME}Pull Artifacts
# Example: conan download zlib/1.3.1 -r cnb-conan-repo
conan download <PACKAGE_NAME> -r <REMOTE_NAME>Build and Push Artifacts
# Create the package locally first
# Example 1: conan create .
# Example 2: conan create . --user=test-user --channel=test-channel
conan create . --user=<USER> --channel=<CHANNEL>
# Upload the package to the remote
# Example 1: conan upload my-project/1.0.0 -r cnb-conan-repo (without user and channel)
# Example 2: conan upload my-project/1.0.0@test-user/test-channel -r cnb-conan-repo (with user and 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 supported. Pushing a different revision is 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.