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:
- 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.
- You also need to create the artifacts.properties file in your Conan home containing the build information. All this properties will be automatically associated to all the published artifacts.
artifact_property_build.name=MyBuild artifact_property_build.number=23 artifact_property_build.timestamp=1487676992
- 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
- Call the command conan_build_info passing the path to the generated Conan traces file and a parameter
--outputto 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
Edit the build_info.json file to append
number(build number) and the
started(started date) and any other field that you need according to the Build Info json format.
startedfield has to be in the format:
To edit the file you can import the json file using the programming language you are using in your framework, groovy, java, python…
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"