4

I want to Archive the artifacts of my program, but when the build failes he doesn't save the artifacts. Why is this?

Because I only want to read the artifact when the job failed!

Thanks for your response!

--

Always when the job fails, I didn't get the artifact. I test it in very small jobs:

Empty batch file + artifact a file, Result: Job Succesfull, Artifact: succesfull

Exit 1 in batch file + artifact a file, Result: Job fails, Artifact: didn't do anything

config.xml file of the job:

<?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> 
4

2 回答 2

5

无论构建是否失败,都会归档工件。确保以下几点:

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

也看看这个相关的问题

于 2012-06-07T09:44:05.063 回答
2

在“归档工件”步骤中,单击高级按钮。取消选中“仅在构建成功时存档工件”因此即使您的单元测试失败,您也将存档工件。

于 2016-08-10T06:22:27.330 回答