ARTIFACTORY: How to build and deploy the conan package to Artifactory

AuthorFullName__c
Janardhana JL
articleNumber
000005564
FirstPublishedDate
2023-01-30T15:49:07Z
lastModifiedDate
2025-07-22

ARTIFACTORY: How to build and deploy the conan package to Artifactory

Prerequisites: Conan client and Cmake compiler.

If you would like to build and upload from local server:-

1. Create a project template (conan new mypkg/0.1 -m=cmake_lib)

 2. Make sure it builds and creates (conan create .) (you will need cmake + compiler installed on the system)

3. Now add a dependency. Open conanfile.py and add a dependency, for example “requires = openssl/1.1.1o, "zlib/1.2.11" there (as a class attribute).

Example:

from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout
class NewpkgConan(ConanFile):
    name = "newpkg"
    version = "1.0.0"
    requires = "openssl/1.1.1o@", “zlib/1.2.11@”
    # Optional metadata


4. Repeat the package creation using “conan create .” or “conan create . --build=missing”(if no precompiled binaries exist in the upstream). You should see the dependency downloaded/ created.

5. Follow the SetMeUp page to add the Artifactory local repository

6. Upload the package ( conan upload mypkg* -r=myrepo --all -c)
 

Using Jenkins:

Prerequisites:  Artifactory Jenkins plugin, conan client and the Cmake compiler.

Sample project:

https://github.com/janardhanajl/conan-test.git

Jenkins pipeline Script
def artifactory_name = "replication"
def artifactory_repo = "conan-local" 
def repo_url = 'https://github.com/janardhanajl/conan-test.git'
def repo_branch = "master"
def recipe_folder = "recipes/newpkg/1.0.0"  
def recipe_version = "1.0.0"
node {
    def server = Artifactory.server artifactory_name
    def client = Artifactory.newConanClient()
    def serverName = client.remote.add server: server, repo: artifactory_repo
    stage("Get recipe"){
        git branch: repo_branch, url: repo_url
    }

    stage("Test recipe"){
        dir (recipe_folder) {
          client.run(command: "create . 1.0.0@"  )
        }
    }
    stage("Upload packages"){
        String command = "upload newpkg -r $serverName  --all --confirm"  
        def b = client.run(command: command)
        server.publishBuildInfo b
    }
}


If you find any issues during the conan package upload or download you can add the debug logger below in the Artifactory logback.xml file under $ARTIFACTORY_HOME/etc/artifactory/logback.xml.
 

<appender name="conan" class="ch.qos.logback.core.rolling.RollingFileAppender">  <File>${log.dir}/artifactory-conan.log</File>
  <rollingPolicy class="org.jfrog.common.logging.logback.rolling.FixedWindowWithDateRollingPolicy">
<FileNamePattern>${log.dir.archived}/artifactory-conan.%i.log.gz</FileNamePattern>
    <maxIndex>10</maxIndex>
  </rollingPolicy>
  <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
    <MaxFileSize>25MB</MaxFileSize>
  </triggeringPolicy>
  <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
    <layout class="org.jfrog.common.logging.logback.layout.BackTracePatternLayout">
      <pattern>%date{yyyy-MM-dd'T'HH:mm:ss.SSS, UTC}Z [jfrt ] [%-5p] [%-16X{uber-trace-id}] [%-30.30(%c{3}:%L)] [%-20.20thread] - %m%n</pattern>
    </layout>
  </encoder>
</appender>
<logger name="org.jfrog.repomd.conan" additivity="false">
<level value="debug"/>
<appender-ref ref="conan"/>
</logger>
<logger name="org.artifactory.addon.conan" additivity="false">
<level value="debug"/>
<appender-ref ref="conan"/>
</logger>


And also enable the trace logs at the local server side.

#Debug logs for Conan - Check /tmp/conan_trace.log after
export CONAN_TRACE_FILE=/tmp/conan_trace.log


If you notice any issues during upload/downloading of the packages, reproduce the issue by enabling the above loggers while executing respective commands and share the trace.log file and Artifactory support bundle with JFrog Support to further debug the issue.

Example 

conan install <package>
conan upload <package> -r=myrepo