首页 > 解决方案 > Conan Artifactory Jenkins 集成失败

问题描述

我们有一个关于使用柯南的 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 配方构建的),将包上传到我们的工件实例,最后我们要清除柯南缓存(通过“conan remove * -f”命令)。

但是这最后一步总是失败:问题似乎是由conanClient引起的,它在“conan remove * -f”之后隐式调用“conan_build_info”命令。“conan_build_info”命令失败,因为“conan_build_info”显然需要“package”缓存,当然,它已被清除。这是一个 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, with the same build-info instance as an argument:
       conanClient.run(command: command, buildInfo: buildInfo)
   }
   
   stage('Publish build info')
   {   
        // Publish the build-info to Artifactory:
       server.publishBuildInfo buildInfo
   }

}

詹金斯日志中的错误:

[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

标签: jenkinsjenkins-pipelinejenkins-pluginsartifactoryconan

解决方案


推荐阅读