詹金斯如何在 docker 容器中调用柯南?错误无法执行脚本柯南

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

使用 Docker 作为构建环境,我的 jenkinsfile 开始指定 docker 容器并调用 CMake,它使用 conan 等触发构建过程。不幸的是管道失败,输出如下:

-- 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):

不知道是什么问题。如果我启动容器并手动构建它,它就可以工作。 如果我手动创建它,则会出现以下错误:

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

我在我的 jenkins 文件中添加了以下环境变量。然后它就可以工作了!我试图在 docker 容器中定义 env 变量,但我失败了

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