构建失败时,Jenkins会保存工件

Dan*_*ans 4

我想存档我的程序的工件,但是当构建失败时,他不会保存工件.为什么是这样?

因为我只想在作业失败时读取工件!

感谢您的答复!

-

总是当工作失败时,我没有得到工件.我在非常小的工作中测试它:

空批处理文件+工件文件,结果:Job Succesfull,Artifact:succesfull

在批处理文件中退出1 +工件文件,结果:作业失败,工件:没有做任何事情

该作业的config.xml文件:

<?xml version='1.0' encoding='UTF-8'?>
<project>
  <actions/>
  <description></description>
  <keepDependencies>false</keepDependencies>
  <properties/>
  <scm class="hudson.scm.NullSCM"/>
  <canRoam>true</canRoam>
  <disabled>false</disabled>
  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
  <triggers class="vector"/>
  <concurrentBuild>false</concurrentBuild>
  <customWorkspace>C:\test\</customWorkspace>
  <builders>
    <hudson.tasks.BatchFile>
      <command>exit 1</command>
    </hudson.tasks.BatchFile>
  </builders>
  <publishers>
    <hudson.tasks.ArtifactArchiver>
      <artifacts>tomcat\logs\tomcat.log</artifacts>
      <latestOnly>false</latestOnly>
    </hudson.tasks.ArtifactArchiver>
  </publishers>
  <buildWrappers/>
</project> 
Run Code Online (Sandbox Code Playgroud)

mal*_*cot 5

无论构建是否失败,都会归档工件.确保以下内容:

  • 您正在查看实际的最后构建工件,而不是"上次成功构建"工件.
  • 生成工件的构建步骤(或将它们复制到工作空间中以进行存档)实际上会运行 - 如果它应该在失败后运行,它将无法运行.在这种情况下,您需要一个取决于您的具体情况的解决方法.

另请看一下这个相关的问题.