Use a generic CI with Conan and Artifactory

Uploading the BuildInfo

If you are using Jenkins with Conan and Artifactory, along with the Jenkins Artifactory Plugin, any Conan package downloaded or uploaded during your build will be automatically recorded in the BuildInfo json file, that will be automatically uploaded to the specified Artifactory instance.

However, you can gather and upload that information using other CI infrastructure with the following steps:

  1. Before calling Conan the first time in your build, set the environment variable CONAN_TRACE_FILE to a file path. The generated file will contain the BuildInfo json.

  2. You also need to create the file in your Conan home containing the build information. All this properties will be automatically associated to all the published artifacts.
  1. Call Conan as many times as you need. For example, if you are testing a Conan package and uploading it at the end, you will run something similar to:

$ conan create . user/stable # Will retrieve the dependencies and create the package
$ conan upload mypackage/1.0@user/stable -r artifactory
  1. Call the command conan_build_info passing the path to the generated Conan traces file and a parameter --output to indicate the output file. You can also, delete the traces.log` file` otherwise while the CONAN_TRACE_FILE is present, any Conan command will keep appending actions.

$ conan_build_info /tmp/traces.log --output /tmp/build_info.json
$ rm /tmp/traces.log
  1. Edit the build_info.json file to append name (build name), number (build number) and the started (started date) and any other field that you need according to the Build Info json format.

    The started field has to be in the format: yyyy-MM-dd'T'HH:mm:ss.SSSZ

    To edit the file you can import the json file using the programming language you are using in your framework, groovy, java, python…

  2. Push the json file to Artifactory, using the REST-API:

curl -X PUT -u<username>:<password> -H "Content-type: application/json" -T /tmp/build_info.json "http://host:8081/artifactory/api/build"