Conan Artifactory Jenkins 集成失败

问题描述

我们在使用 Conan 的 Jenkins Artifactory 插件方面遇到了问题。

基本上,我们创建了我们的脚本管道(遵循 https://github.com/jfrog/project-examples/blob/master/jenkins-examples/pipeline-examples/scripted-examples/conan-example/Jenkinsfile 中的示例),它设置工件服务器,创建 conanClient,执行创建 Conan 包(通过运行 conanClient 命令“ conan create”,因为我们的项目是通过 conanfile.py recipe 构建的),将包上传到我们的 artifactory 实例,最后我们要清除 conan 缓存(通过“conan remove * -f”命令)。

但这最后一步总是失败:问题似乎是由 conanClient 引起的,它在“conan remove * -f”之后隐式调用了“conan_build_info”命令。 “conan_build_info”命令失败,因为“conan_build_info”显然需要“包”缓存,当然,它被清除了。这是一个 conanClient 错误(也许是因为,正如我们在文档中所读到的,不建议使用 conan_build_info 命令:https://docs.conan.io/en/latest/reference/commands/misc/conan_build_info.html),还是我们遗漏了什么? 有没有办法通过 ConanClient 执行包创建和上传,并在不导致管道失败的情况下清除柯南缓存? 在我看来,这是一个很大的虚假错误,因为通过 CI 创建和上传包 - Jenkins 是一个基本方面......当然,最后,必须清除柯南缓存......

这里是我们的 Jenkinsfile:

node()
{
   // Obtain an Artifactory server instance,defined in Jenkins --> Manage:
   def server = Artifactory.server "artifactory_server"

   // Create a local build-info instance:
   def buildInfo = Artifactory.newBuildInfo()
   buildInfo.name = "our git master pipeline"

   // Create a conan client instance:
   def conanClient = Artifactory.newConanClient()

   // Add a new repository named 'conan-local' to the conan client.
   // The 'remote.add' method returns a 'serverName' string,which is used later in the script:
   String serverName = conanClient.remote.add server: server,repo: "conan-local"
   
   // We enable strict ABI dependency propagation
   conanClient.run(command: "config set general.default_package_id_mode=package_revision_mode",buildInfo: buildInfo)
   conanClient.run(command: "config set general.revisions_enabled=1",buildInfo: buildInfo)
   conanClient.run(command: "config set general.full_transitive_package_id=1",buildInfo: buildInfo)
       
   stage('Checkout') 
   {
       // checkout from our repo...
   }

   stage('Build Release')
   {
       // Run a conan build. The 'buildInfo' instance is passed as an argument to the 'run' method:
       conanClient.run(command: "create ./project_dir channel/channel",buildInfo: buildInfo)
   }
   
   stage('Upload')
   {   
       // Create an upload command. The 'serverName' string is used as a conan 'remote',so that the artifacts are uploaded into it:
       String command = "upload our_packet/*@*/master --all -r ${serverName} --confirm"

       // Run the upload command,with the same build-info instance as an argument:
       conanClient.run(command: command,buildInfo: buildInfo)
   }

   stage("Clear Conan Cache")  
   {
       // Clean all conan cache
       String command = "remove * -f"

       // Run the remove command,buildInfo: buildInfo)
   }
   
   stage('Publish build info')
   {   
        // Publish the build-info to Artifactory:
       server.publishBuildInfo buildInfo
   }

}

Jenkins 日志中的错误

[out_project] $ cmd.exe /C "conan remove "*" -f && exit %%ERRORLEVEL%%"
[out_project] $ cmd.exe /C "conan_build_info D:\jenkins\workspace\out_project@tmp\artifactory\conan.tmp8862200414119894885\conan_log.log --output D:\jenkins\workspace\out_project@tmp\artifactory\conan1112119574977543529build-info && exit %%ERRORLEVEL%%"
[1m[31mERROR: [Errno 2] No such file or directory: 'D:\\.conan\\efa5c5\\1\\conaninfo.txt'[0m
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
java.lang.RuntimeException: Conan build Failed
   at org.jfrog.hudson.pipeline.common.Utils.launch(Utils.java:256)
   at org.jfrog.hudson.pipeline.common.executors.ConanExecutor.execute(ConanExecutor.java:132)
   at org.jfrog.hudson.pipeline.common.executors.ConanExecutor.collectConanBuildInfo(ConanExecutor.java:180)
   at org.jfrog.hudson.pipeline.common.executors.ConanExecutor.execCommand(ConanExecutor.java:101)
   at org.jfrog.hudson.pipeline.scripted.steps.conan.runcommandStep$Execution.runStep(runcommandStep.java:50)
   at org.jfrog.hudson.pipeline.scripted.steps.conan.runcommandStep$Execution.runStep(runcommandStep.java:37)
   at org.jfrog.hudson.pipeline.ArtifactorySynchronousNonBlockingStepExecution.run(ArtifactorySynchronousNonBlockingStepExecution.java:42)
   at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
   at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)