Conan Builds with Artifactory - Declarative Pipeline Syntax

JFrog Integrations Documentation

Content Type

Conan is a C/C++ Package Manager. The Artifactory Pipeline DSL includes APIs that make it easy for you to run Conan builds, using the Conan Client installed on your build agents. Here's what you need to do before you create your first Conan build job with Jenkins:

1, Install the latest Conan Client on your Jenkins build agent. Please refer to the Conan documentation for installation instructions.

2. Add the Conan Client executable to the PATH environment variable on your build agent, to make sure Jenkins is able to use the client.

3. Create a Conan repository in Artifactory as described in the Conan Repositories Artifactory documentation.Conan Repositories

OK. Let's start coding your first Conan Pipeline script.

Let's start by creating a Conan Client instance:

rtConanClient (
    id: "myConanClient"

When creating the Conan client, you can also specify the Conan user home directory as shown below:

rtConanClient (
    id: "myConanClient",
        userHome: "conan/my-conan-user-home"

We can now configure our new conan client by adding an Artifactory repository to it. In our example, we're adding the 'conan-local' repository, located in the Artifactory server, referenced by the pre-configured server ID:

rtConanRemote (
    name: "myRemoteName",
    serverId: "Artifactory-1",
    repo: "conan-local",
    clientId: "myConanClient",
        // Optional - Adding this argument will make the conan client not to raise an error. If an existing remote exists with the provided name.
        force: true,
        // Optional - Adding this argument will make the conan client skip the validation of SSL certificates.
        verifySSL: false

OK. We're ready to start running Conan commands. You'll need to be familiar with the Conan commands syntax, exposed by the Conan Client to run the commands. You can read about the commands syntax in the Conan documentation.

Let's run the first command:

rtConanRun (
    clientId: "myConanClient",
    command: "install . --build missing"

The next thing we want to do is to use the conan remote we created. For example, let's upload our artifacts to the conan remote. Notice how we use the ID of the remote we created earlier, which is myRemoteName:

rtConanRun (
    clientId: "myConanClient",
    command: "upload * --all -r myRemoteName --confirm"

We can now publish the the buildInfo to Artifactory, as described in the Publishing Build-Info to Artifactory section:

rtPublishBuildInfo (
    serverId: "Artifactory-1"