Search code examples
jenkinscmakeconan

How to invoke conan in docker container by jenkins? error Failed to execute script conan


Using Docker as a build environment, My jenkinsfile starting specified docker container and invoking CMake which trigger build process using conan and so on. Unfortunately pipeline failed with the following output:

-- Conan: checking conan executable
-- Conan: Found program /usr/bin/conan
-- Conan: Version found [148] Failed to execute script conan
 Traceback (most recent call last):
  File "conan/conans/conan.py", line 11, in <module>
 File "conan/conans/conan.py", line 7, in run
 File "conan/conans/client/command.py", line 2151, in main
 File "conan/conans/client/conan_api.py", line 222, in factory
 File "conan/conans/client/conan_api.py", line 234, in __init__
 File "conan/conans/client/migrations.py", line 26, in __init__
 File "conan/conans/client/cache/cache.py", line 78, in __init__
File "conan/conans/client/cache/cache.py", line 150, in config
  File "conan/conans/util/files.py", line 190, in save
 FileNotFoundError: [Errno 2] No such file or directory: '/.conan/conan.conf'
-- Conan executing: /usr/bin/conan install . -s build_type=Release -s compiler=clang -s compiler.version=10 -s compiler.libcxx=libstdc++11 -g=cmake --build=missing
[176] Failed to execute script conan
 Traceback (most recent call last):

I do not know what the problem is. If I start container and build it manually it works. If I create it manually then I am getting following error:

Conan: Version found ERROR: Can't write version file in /.conan/version.txt

Solution

  • I added the following environment variable to my jenkinsfile. Then it simply works!. I was trying to define env variables in docker container that was my fail

      environment {
            CONAN_USER_HOME = "${env.WORKSPACE}/"
            CONAN_NON_INTERACTIVE = 1
        }