Use Conan with JFrog CLI

Configure jf conan to resolve and publish Conan packages through JFrog Artifactory.

Run native Conan commands with Artifactory integration and optional build-info collection.

This topic covers the following tasks:

When to Use

Use jf conan to run Conan C/C++ package manager commands with Artifactory integration. This enables:

  • Resolving Conan packages from Artifactory's Conan repository
  • Publishing packages to Artifactory
  • Collecting build-info for C/C++ builds
📘

Package Alias (Ghost Frog)

Package Alias does not intercept conan commands. Supported tools are mvn, gradle, npm, yarn, pnpm, go, pip, pipenv, poetry, dotnet, nuget, docker, gem, and bundle. See Use JFrog CLI Package Alias for setup and the full tool list.

Prerequisites

  • Conan must be installed. Install via pip:

    pip install conan

    Verify with conan --version. For full installation options, see the Conan installation docs.

  • Conan remote configured to point to your Artifactory Conan repository, either manually:

    conan remote add artifactory https://<your-instance>.jfrog.io/artifactory/api/conan/<repo-name>

    or with jf conan-config (see Configuration: jf conan-config).

  • JFrog CLI configured with a server connection. See jf config add.

  • Authentication to Artifactory is required.

  • A Conan project directory containing a conanfile.py or conanfile.txt. The jf conan install command works with either file, while jf conan create requires a conanfile.py.


Configuration: jf conan-config

jf conan-config (alias: jf conanc) writes a per-project Conan configuration (.jfrog/projects/conan.yaml) and configures your local Conan remote so that jf conan resolves through an Artifactory Conan repository. This is an alternative to configuring Conan manually with conan remote add (see Prerequisites).

To configure Conan with Artifactory:

  1. Configure a server with jf config add (see Prerequisites).
  2. Run jf conan-config with the resolution and/or deployment repository and server flags.

Synopsis

jf conan-config [options]

Aliases: conanc

Options

FlagDefaultDescription
--globalfalseSet to true to make the configuration global (for all projects). Specific projects can override it.
--repo-resolveRepository for dependencies resolution.
--repo-deployRepository for artifacts deployment.
--server-id-resolveArtifactory server ID for resolution. The server should be configured using jf config add.
--server-id-deployArtifactory server ID for deployment. The server should be configured using jf config add.

If a required flag is omitted, jf conan-config prompts for it interactively.

For example:

jf conan-config --server-id-resolve=my-server --repo-resolve=conan-virtual

This has the effect described above — the project and Conan remote are now configured to resolve through the specified Artifactory repository.


Build: jf conan

Run native Conan commands with Artifactory integration and optional build-info collection.

To run Conan with Artifactory integration:

  1. Install Conan, configure an Artifactory remote, and open a directory with a conanfile.py or conanfile.txt (see Prerequisites).
  2. Run jf conan with the Conan subcommand and arguments, adding --build-name and --build-number when you want build-info (see Build Examples).

Synopsis

jf conan <conan-arguments> [options]

Aliases: none

Arguments

ArgumentRequiredDescription
<conan-arguments>YesArguments and options for the Conan command (for example, install, create)

Build Options

FlagDefaultDescription
--build-nameBuild name for build-info. Requires --build-number.
--build-numberBuild number for build-info. Requires --build-name.
--moduleOptional module name for build-info. Requires --build-name and --build-number.
--projectJFrog Artifactory project key

Build Examples

📘

Note

Run these commands from a directory containing a conanfile.py or conanfile.txt. The . argument refers to the current directory where your Conan recipe lives.

View Help

jf conan --help

Install Dependencies with Build-Info

jf conan install . --build=missing --build-name=<build-name> --build-number=<build-number>

Where:

  • . is the path to the directory containing your conanfile.py or conanfile.txt
  • --build=missing builds packages from source if pre-built binaries are not available
  • <build-name> is a name for the build (for example, my-cpp-app)
  • <build-number> is a number or identifier for the build run (for example, 1)

For example:

jf conan install . --build=missing --build-name=my-cpp-app --build-number=1

On success, the output ends with:

Install finished successfully
[Info] Conan build info collected. Use 'jf rt bp my-cpp-app 1' to publish it.

Create a Package

This command requires a conanfile.py (a conanfile.txt is not sufficient for conan create).

jf conan create . --name=hello --version=1.0 --build-name=<build-name> --build-number=<build-number>

For example:

jf conan create . --name=hello --version=1.0 --build-name=my-cpp-app --build-number=1

On success, the output ends with:

hello/1.0: Package '<package-id>' created
[Info] Conan build info collected. Use 'jf rt bp my-cpp-app 1' to publish it.

Upload Packages to Artifactory

After creating a package, upload it to your Artifactory Conan repository:

jf conan upload "<pattern>" -c -r <remote-name> --build-name=<build-name> --build-number=<build-number>

Where:

  • <pattern> is the package reference pattern to upload (use "*" to upload all packages)
  • -c confirms the upload without prompting
  • <remote-name> is the remote name configured with conan remote add
  • <build-name> is a name for the build
  • <build-number> is a number or identifier for the build run

For example:

jf conan upload "hello/1.0" -c -r artifactory --build-name=my-cpp-app --build-number=1

Publish Build Info

After uploading, publish the collected build info to Artifactory:

jf rt build-publish <build-name> <build-number>

For example:

jf rt build-publish my-cpp-app 1
👍

Tip

jf rt bp is a shorthand alias for jf rt build-publish.


Important Notes

  • jf conan-config: optional alternative to manual conan remote add — see Configuration: jf conan-config.
  • Conan 2.x compatibility: The examples on this page use Conan 2.x syntax. Conan 1.x uses different flags (for example, --all for upload), which are not supported in Conan 2.x. Verify your version with conan --version and jf --version.
  • Build-info: Use --build-name and --build-number to track dependencies and artifacts. After running your Conan commands, publish the build info with jf rt build-publish <build-name> <build-number> (alias: jf rt bp).

CI/CD Example: GitHub Actions

# .github/workflows/build.yml
steps:
  - uses: actions/checkout@v4
  - name: Setup JFrog CLI
    uses: jfrog/setup-jfrog-cli@v4
    env:
      JF_URL: ${{ vars.JF_URL }}
      JF_ACCESS_TOKEN: ${{ secrets.JF_ACCESS_TOKEN }}
  - name: Setup Conan
    run: |
      pip install conan
      conan remote add artifactory https://acme.jfrog.io/artifactory/api/conan/conan-local
  - name: Install dependencies
    run: jf conan install . --build=missing --build-name=my-cpp-app --build-number=${{ github.run_number }}
  - name: Upload packages
    run: jf conan upload "*" -c -r artifactory --build-name=my-cpp-app --build-number=${{ github.run_number }}
  - name: Publish build info
    run: jf rt build-publish my-cpp-app ${{ github.run_number }}

Troubleshooting

SymptomCauseFix
Conanfile not foundNo conanfile.py or conanfile.txt in the directory passed to the commandCreate a conanfile.py or conanfile.txt in your project directory, or pass the correct path instead of .
Conan cannot resolve from ArtifactoryConan remote not configuredRun conan remote add artifactory <artifactory-conan-url>
401 / 403 on uploadInvalid credentials or insufficient permissionsRe-run jf config add; verify conan remote credentials
unrecognized arguments: --allUsing Conan 1.x flags with Conan 2.xReplace --all with -c (confirm). See the Conan 2 migration guide.
Conan 2.x compatibility issuesCLI version and Conan version mismatchCheck conan --version and jf --version for compatibility
Build-info not collected--build-name and --build-number not passedAdd both flags to the Conan command
command not found: conanConan not installed or not on PATHInstall with pip install conan. If already installed, add the pip scripts directory to your PATH.

Enable debug logging: export JFROG_CLI_LOG_LEVEL=DEBUG


Frequently Asked Questions

This section provides answers to frequently asked questions about using Conan with JFrog CLI.

plusFAQs
Q: How do I run Conan commands with build-info collection?

A: Run jf conan with your Conan subcommand and arguments, then add --build-name and --build-number to collect build-info. Publish the result with jf rt build-publish. See Build: jf conan.

Q: What do I need before using jf conan with Artifactory?

A: You need Conan installed, a Conan remote configured to point at your Artifactory Conan repository, a configured JFrog CLI server connection, and a project directory containing conanfile.py or conanfile.txt. See Prerequisites.

Q: What is the difference between conan install and conan create for build-info?

A: jf conan install works with either conanfile.py or conanfile.txt, while jf conan create requires a conanfile.py. Both collect build-info when --build-name and --build-number are passed. See Build Examples.

Q: Why does jf conan upload fail with unrecognized arguments: --all?

A: That flag is from Conan 1.x. Conan 2.x replaces it with -c to confirm the upload without prompting. See Important Notes and the Troubleshooting table.

Q: Does Package Alias intercept conan commands?

A: No. Package Alias does not intercept conan commands. See Use JFrog CLI Package Alias for the full list of supported tools.

Related Topics


Did this page help you?