简体   繁体   English

如何从groovy Postbuild插件访问Jenkins构建工件?

[英]How can I access Jenkins build artifacts from the groovy Postbuild plugin?

Is there a way to read a build artifact file using the Groovy postbuild plugin? 有没有一种方法可以使用Groovy postbuild插件读取构建工件文件?

Some context: I have written some testng tests that are run by maven in Jenkins. 一些背景信息:我写了一些Jenkins中由maven运行的testng测试。 Jenkins runs the tests, gives me the test results, etc. However, I have been asked to also store the results in HP's Application Lifeycycle Management (ALM). 詹金斯(Jenkins)运行测试,向我提供测试结果,等等。但是,有人要求我也将结果存储在HP的Application Lifeycycle Management(ALM)中。 A coworker provided me with a post-build groovy script that can interface with ALM and store the test results. 一位同事为我提供了可与ALM交互并存储测试结果的构建后Groovy脚本。 I have to pass these parameters to that script: 我必须将这些参数传递给该脚本:

  • jobname 作业名
  • pass/fail status 通过/失败状态
  • test start time 测试开始时间

My idea was to store testng-results.xml as an artifact and parse out the results with xmlslurper, but I don't know how to read the artifact from the groovy plugin. 我的想法是将testng-results.xml作为工件存储,并使用xmlslurper解析结果,但是我不知道如何从groovy插件读取工件。 From the groovy postbuild plugin page I have gathered that it might also be possible to read the test results directly from the manager.build variable, but I don't have a lot of experience with Jenkins or this plugin and so far I have been unsuccessful. groovy postbuild插件页面中,我已经收集到,也有可能直接从manager.build变量中读取测试结果,但是我对Jenkins或此插件没有太多经验,到目前为止,我还没有成功。

I'm also open to other approaches as well. 我也对其他方法持开放态度。 The groovy script is running on the Jenkins server, not on the slave node. groovy脚本在Jenkins服务器上运行,而不是在从属节点上运行。

万一这对将来的任何人有用,我所采用的解决方案是在manager.build.getArtifacts()查找所需的工件,并将该路径与manager.build.getArtifactsDir()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM