Conan: [question] Conan in Jenkinsfile CI: How to obtain package reference *before* a conan create action has taken place?

Created on 4 Jan 2021  路  2Comments  路  Source: conan-io/conan

We are following through the examples in https://docs.conan.io/en/latest/versioning/lockfiles/ci.html#package-pipeline and we get to a point where we have already run the conan lock create --base "package" lockfile creation steps and we are now trying to follow the @memsharded suggestion in https://github.com/conan-io/conan/issues/8205#issuecomment-744752830 to run the conan export . <package referecem> --lockfile command:

run("conan export . libb/0.2@user/testing --lockfile=../locks/libb_deps_base.lock "
            "--lockfile-out=../locks/libb_base.lock")

This is from:

https://github.com/conan-io/examples/blob/master/features/lockfiles/ci/build.py#L80

How do we get libb/0.2@user/testing programmatically in a generic CI which reads conanfiles from our github?

I know how to obtain libb/0.2@user/testing from json output of conan create commands, but this export step is required to happen before conan create.

question

All 2 comments

Hi!

Some recipes can define a name or version hardcoded in the conanfile.py itself. You need to run conan export to get the full reference. Alternatively you can ran conan inspect to get the values for the name and version attributes. This is more or less what it is said here https://github.com/conan-io/conan/issues/6554.

But you will always need to know the path to the conanfile.py and the user/channel you want to use (if any). With it, you can run conan inspect <path/to/conanfile.py> -j output.json and read the name and version from the output. Then you can build the full Conan reference.

Thank you! https://docs.conan.io/en/latest/reference/commands/misc/inspect.html works:

C:\dev\src\nx\AcquisitionSupport>conan inspect . -j inspect-output.json
Loaded debian\changelog to parse version[13.6.6] commitAtVersion[7951906]
name: nxas
version: 13.6.6
url: [email protected]:nx/AcquisitionSupport.git
homepage: None
license: None
author: None
description: my support library
topics: None
generators: cmake
exports: debian/changelog
exports_sources: None
short_paths: True
apply_env: True
build_policy: None
revision_mode: hash
settings: ('os', 'compiler', 'arch', 'build_type')
options:
    shared: [True, False]
default_options:
    shared: False

inspect-output.json


{"name": "nxas", "version": "13.6.6", "url": "[email protected]:nx/AcquisitionSupport.git", "homepage": null, "license": null, "author": null, "description": "my support library", "topics": null, "generators": "cmake", "exports": "debian/changelog", "exports_sources": null, "short_paths": true, "apply_env": true, "build_policy": null, "revision_mode": "hash", "settings": ["os", "compiler", "arch", "build_type"], "options": {"shared": [true, false]}, "default_options": "shared=False"}
Was this page helpful?
0 / 5 - 0 ratings