Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-10502

Add an option to make archiving the artifacts non-fatal if they don't exist

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • core
    • None
    • Jenkins 1.421

      If you tick the box to enable "Archive the artifacts", populate the "Files to archive", and your build fails to output those artifacts it will fail with something like this:

      12:11:51  Archiving artifacts
      12:11:51  ERROR: No artifacts found that match the file pattern "tfields/Live/Engine/Tools/Layout.*". Configuration error?
      12:11:57  ERROR: 'tfields/Live/Engine/Tools/Layout.*' doesn't match anything: 'tfields' exists but not 'tfields/Live/Engine/Tools/Layout.*'
      12:11:57  Build step 'Archive the artifacts' changed build result to FAILURE
      

      Depending on what your build actually does, those artifacts might not always be created. I'd like to propose that you add an option to make the archiving of artifacts non fatal.

      Thanks,
      Tom.

          [JENKINS-10502] Add an option to make archiving the artifacts non-fatal if they don't exist

          I am using this option to record test artifacts which exist only when the test fails. Currently I have to place a dummy in the test screenshots directory, which is unpleasant.

          Robert Munteanu added a comment - I am using this option to record test artifacts which exist only when the test fails. Currently I have to place a dummy in the test screenshots directory, which is unpleasant.

          Thomas Fields added a comment -

          Can Jenkins core be updated to support my request? Does this issue need assigning to someone?

          Cheers,
          Tom.

          Thomas Fields added a comment - Can Jenkins core be updated to support my request? Does this issue need assigning to someone? Cheers, Tom.

          I'm in exactly the same situation as rombert. It would be great to have an option so the build does not fail automatically when there are no artifacts.

          David Santiago Turiño added a comment - I'm in exactly the same situation as rombert. It would be great to have an option so the build does not fail automatically when there are no artifacts.

          +1. This feature would be very useful.

          Stéphane Van Espen added a comment - +1. This feature would be very useful.

          Thomas Fields added a comment -

          If only I knew who to assign this to so it actually gets implemented.

          Thomas Fields added a comment - If only I knew who to assign this to so it actually gets implemented.

          lukas rytz added a comment -

          lukas rytz added a comment - check https://wiki.jenkins-ci.org/display/JENKINS/Features+controlled+by+system+properties for hudson.tasks.ArtifactArchiver.warnOnEmpty

          Thomas Fields added a comment -

          Thanks for that, it sounds like the biggest hack ever. We should be able to configure this on a project level and not globally for the whole system.

          Cheers,
          Tom.

          Thomas Fields added a comment - Thanks for that, it sounds like the biggest hack ever. We should be able to configure this on a project level and not globally for the whole system. Cheers, Tom.

          Tuukka Mustonen added a comment - - edited

          Same problem here. I set the hudson.tasks.ArtifactArchiver.warnOnEmpty to /etc/default/jenkins (came with jenkins debian-package) and it seems to work.

          Still, "optional" checkbox in job configuration would be nice.

          Tuukka Mustonen added a comment - - edited Same problem here. I set the hudson.tasks.ArtifactArchiver.warnOnEmpty to /etc/default/jenkins (came with jenkins debian-package) and it seems to work. Still, "optional" checkbox in job configuration would be nice.

          Dave Hunt added a comment -

          We're having this issue too. Screenshots are taken on failure, but when there are no failures (and no screenshots) the build fails anyway! It would be great if this could be configured on a per job basis rather than the global property mentioned above.

          Dave Hunt added a comment - We're having this issue too. Screenshots are taken on failure, but when there are no failures (and no screenshots) the build fails anyway! It would be great if this could be configured on a per job basis rather than the global property mentioned above.

          Julian M. added a comment -

          This would be an useful enhancement. We are using this feature for archiving screenshots of failed tests, too.

          Julian M. added a comment - This would be an useful enhancement. We are using this feature for archiving screenshots of failed tests, too.

          bap added a comment -

          Install the flexible publish plugin and use the file exists or the files match run condition

          bap added a comment - Install the flexible publish plugin and use the file exists or the files match run condition

          Gaston Falco added a comment -

          I would love to have this option.

          Gaston Falco added a comment - I would love to have this option.

          bap added a comment -

          From above: "Install the flexible publish plugin and use the file exists or the files match run condition"

          Put the files that you want to archive in the run condition (File exists or Files match), it will then only run "Archive the artifacts" if those files are found.

          https://wiki.jenkins-ci.org/display/JENKINS/Flexible+Publish+Plugin

          bap added a comment - From above: "Install the flexible publish plugin and use the file exists or the files match run condition" Put the files that you want to archive in the run condition (File exists or Files match), it will then only run "Archive the artifacts" if those files are found. https://wiki.jenkins-ci.org/display/JENKINS/Flexible+Publish+Plugin

          This was reported 2 years ago and it isn't even assigned?

          Pedro Rodriguez added a comment - This was reported 2 years ago and it isn't even assigned?

          evernat added a comment -

          @Pedro
          > "isn't even assigned"
          I see the name of a few people involved in this issue and who can take this issue, including you if you just want to.

          evernat added a comment - @Pedro > "isn't even assigned" I see the name of a few people involved in this issue and who can take this issue, including you if you just want to.

          Pedro Rodriguez added a comment - - edited

          @evarnar: you've motivated me into getting involved!

          I've sent a request for this: https://github.com/jenkinsci/jenkins/pull/732

          Pedro Rodriguez added a comment - - edited @evarnar: you've motivated me into getting involved! I've sent a request for this: https://github.com/jenkinsci/jenkins/pull/732

          Ok guys, so the main issue we are having with this is backwards comparability (aka, still support the System Property setting from before and not crash people's already-existing builds that assumed the property to be on).

          I'm on the side that the SysProp was hacky to begin with so it shouldn't be supported (people that are currently using it would need to configure their builds and check the "do not fail on empty" checkbox). We could write somewhere that this needs to be done.

          Or we could continue to support it (have a duality of new and old builds). If this option, it would be best to automatically transfer people to the new system (by simply hitting "configure" and then save. It would be a simple config.xml change). The issue with this is that it requires code that will only really be used once (for the transfer) and then never used again.

          Again, I'm for the former, but I can see the argument for the latter given that it is commonly used (not sure how many people are using the SysProp though).

          What do you guys think?

          Pedro Rodriguez added a comment - Ok guys, so the main issue we are having with this is backwards comparability (aka, still support the System Property setting from before and not crash people's already-existing builds that assumed the property to be on). I'm on the side that the SysProp was hacky to begin with so it shouldn't be supported (people that are currently using it would need to configure their builds and check the "do not fail on empty" checkbox). We could write somewhere that this needs to be done. Or we could continue to support it (have a duality of new and old builds). If this option, it would be best to automatically transfer people to the new system (by simply hitting "configure" and then save. It would be a simple config.xml change). The issue with this is that it requires code that will only really be used once (for the transfer) and then never used again. Again, I'm for the former, but I can see the argument for the latter given that it is commonly used (not sure how many people are using the SysProp though). What do you guys think?

          lukas rytz added a comment -

          Changing the behavior for people that are currently using the system property is not an option, IMO.

          I think the logic should be something like

          if (archives-non-existent) {
            if (job.onlyWarnOnEmptyArtifacts.isDefined && job.onlyWarnOnEmptyArtifacts.isSet) {
              newWarning();  // or whatever needs to be done
            } else if (systemProperty(warnOnEmpty).isDefined) {
              oldWarning();  // don't change behavior of existing installation.
                             // the system property is still considered even if the new setting exists (and is not enabled) in the job config
                             // (add that to the documentation). the reason: just saving the job config might add the setting to the config,
                             // without the user noticing.
            } else {
              fail();        // default behavior, don't change
            }
          }
          

          lukas rytz added a comment - Changing the behavior for people that are currently using the system property is not an option, IMO. I think the logic should be something like if (archives-non-existent) { if (job.onlyWarnOnEmptyArtifacts.isDefined && job.onlyWarnOnEmptyArtifacts.isSet) { newWarning(); // or whatever needs to be done } else if (systemProperty(warnOnEmpty).isDefined) { oldWarning(); // don't change behavior of existing installation. // the system property is still considered even if the new setting exists (and is not enabled) in the job config // (add that to the documentation). the reason: just saving the job config might add the setting to the config, // without the user noticing. } else { fail(); // default behavior, don't change } }

          Owen Mehegan added a comment -

          This is a case where the "principle of least surprise" should be applied. See http://en.wikipedia.org/wiki/Principle_of_least_astonishment If the proposed change is likely to make a segment of users go, "WTF," then it's better to code around that (within reason).

          It could also be worth asking Kohsuke's opinion.

          Owen Mehegan added a comment - This is a case where the "principle of least surprise" should be applied. See http://en.wikipedia.org/wiki/Principle_of_least_astonishment If the proposed change is likely to make a segment of users go, "WTF," then it's better to code around that (within reason). It could also be worth asking Kohsuke's opinion.

          @lukas:

          I don't actually know how to do that (or if it is possible).

          job.onlyWarnOnEmptyArtifacts.isDefined && job.onlyWarnOnEmptyArtifacts.isSet

          I don't know how to show that to the user. A checkbox (what the user will see when the hit config) is either checked or not checked. And I have to listen to that because the user might check or uncheck it. At the moment, I have it set up so that users with the SysProp will have it checked by default.

          Pedro Rodriguez added a comment - @lukas: I don't actually know how to do that (or if it is possible). job.onlyWarnOnEmptyArtifacts.isDefined && job.onlyWarnOnEmptyArtifacts.isSet I don't know how to show that to the user. A checkbox (what the user will see when the hit config) is either checked or not checked. And I have to listen to that because the user might check or uncheck it. At the moment, I have it set up so that users with the SysProp will have it checked by default.

          lukas rytz added a comment -

          @pedro: setting the default value of the checkbox according to the system property looks also fine to me.

          lukas rytz added a comment - @pedro: setting the default value of the checkbox according to the system property looks also fine to me.

          Code changed in jenkins
          User: Pedro Rodriguez
          Path:
          core/src/main/java/hudson/tasks/ArtifactArchiver.java
          core/src/main/resources/hudson/tasks/ArtifactArchiver/config.jelly
          core/src/main/resources/hudson/tasks/ArtifactArchiver/config.properties
          test/src/test/java/hudson/model/AbstractProjectTest.java
          test/src/test/java/hudson/tasks/ArtifactArchiverTest.java
          test/src/test/java/hudson/tasks/LogRotatorTest.java
          http://jenkins-ci.org/commit/jenkins/d3096819f6a70c107399fbcf2df23718098c926e
          Log:
          JENKINS-10502 Option to make the build NOT fail if there is nothing to archive

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Pedro Rodriguez Path: core/src/main/java/hudson/tasks/ArtifactArchiver.java core/src/main/resources/hudson/tasks/ArtifactArchiver/config.jelly core/src/main/resources/hudson/tasks/ArtifactArchiver/config.properties test/src/test/java/hudson/model/AbstractProjectTest.java test/src/test/java/hudson/tasks/ArtifactArchiverTest.java test/src/test/java/hudson/tasks/LogRotatorTest.java http://jenkins-ci.org/commit/jenkins/d3096819f6a70c107399fbcf2df23718098c926e Log: JENKINS-10502 Option to make the build NOT fail if there is nothing to archive

          Code changed in jenkins
          User: Jesse Glick
          Path:
          core/src/main/java/hudson/tasks/ArtifactArchiver.java
          core/src/main/resources/hudson/tasks/ArtifactArchiver/config.jelly
          core/src/main/resources/hudson/tasks/ArtifactArchiver/config.properties
          core/src/main/resources/hudson/tasks/ArtifactArchiver/help-allowEmptyArchive.html
          test/src/test/groovy/hudson/matrix/MatrixProjectTest.groovy
          test/src/test/java/hudson/model/AbstractProjectTest.java
          test/src/test/java/hudson/tasks/ArtifactArchiverTest.java
          test/src/test/java/hudson/tasks/LogRotatorTest.java
          http://jenkins-ci.org/commit/jenkins/aeb887c12d60987745ed40a55d0f6ddcee503426
          Log:
          Merge pull request #732 from pjrt/JENKINS-10502

          [FIXED JENKINS-10502] Option to make the build not fail if there is nothing to archive

          Compare: https://github.com/jenkinsci/jenkins/compare/77e011a3dae3...aeb887c12d60


          You received this message because you are subscribed to the Google Groups "Jenkins Commits" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-commits+unsubscribe@googlegroups.com.
          For more options, visit https://groups.google.com/groups/opt_out.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: core/src/main/java/hudson/tasks/ArtifactArchiver.java core/src/main/resources/hudson/tasks/ArtifactArchiver/config.jelly core/src/main/resources/hudson/tasks/ArtifactArchiver/config.properties core/src/main/resources/hudson/tasks/ArtifactArchiver/help-allowEmptyArchive.html test/src/test/groovy/hudson/matrix/MatrixProjectTest.groovy test/src/test/java/hudson/model/AbstractProjectTest.java test/src/test/java/hudson/tasks/ArtifactArchiverTest.java test/src/test/java/hudson/tasks/LogRotatorTest.java http://jenkins-ci.org/commit/jenkins/aeb887c12d60987745ed40a55d0f6ddcee503426 Log: Merge pull request #732 from pjrt/ JENKINS-10502 [FIXED JENKINS-10502] Option to make the build not fail if there is nothing to archive Compare: https://github.com/jenkinsci/jenkins/compare/77e011a3dae3...aeb887c12d60 – You received this message because you are subscribed to the Google Groups "Jenkins Commits" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-commits+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out .

          Code changed in jenkins
          User: Jesse Glick
          Path:
          changelog.html
          http://jenkins-ci.org/commit/jenkins/e88932956f78dc8c89835256b820cca671756286
          Log:
          JENKINS-10502 Noting.

          Compare: https://github.com/jenkinsci/jenkins/compare/aeb887c12d60...e88932956f78


          You received this message because you are subscribed to the Google Groups "Jenkins Commits" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-commits+unsubscribe@googlegroups.com.
          For more options, visit https://groups.google.com/groups/opt_out.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: changelog.html http://jenkins-ci.org/commit/jenkins/e88932956f78dc8c89835256b820cca671756286 Log: JENKINS-10502 Noting. Compare: https://github.com/jenkinsci/jenkins/compare/aeb887c12d60...e88932956f78 – You received this message because you are subscribed to the Google Groups "Jenkins Commits" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-commits+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out .

          dogfood added a comment -

          Integrated in jenkins_main_trunk #2381
          JENKINS-10502 Option to make the build NOT fail if there is nothing to archive (Revision d3096819f6a70c107399fbcf2df23718098c926e)
          JENKINS-10502 Noting. (Revision e88932956f78dc8c89835256b820cca671756286)

          Result = SUCCESS
          pjrodriguezt : d3096819f6a70c107399fbcf2df23718098c926e
          Files :

          • test/src/test/java/hudson/tasks/ArtifactArchiverTest.java
          • test/src/test/java/hudson/model/AbstractProjectTest.java
          • core/src/main/java/hudson/tasks/ArtifactArchiver.java
          • core/src/main/resources/hudson/tasks/ArtifactArchiver/config.properties
          • core/src/main/resources/hudson/tasks/ArtifactArchiver/config.jelly
          • test/src/test/java/hudson/tasks/LogRotatorTest.java

          Jesse Glick : e88932956f78dc8c89835256b820cca671756286
          Files :

          • changelog.html

          dogfood added a comment - Integrated in jenkins_main_trunk #2381 JENKINS-10502 Option to make the build NOT fail if there is nothing to archive (Revision d3096819f6a70c107399fbcf2df23718098c926e) JENKINS-10502 Noting. (Revision e88932956f78dc8c89835256b820cca671756286) Result = SUCCESS pjrodriguezt : d3096819f6a70c107399fbcf2df23718098c926e Files : test/src/test/java/hudson/tasks/ArtifactArchiverTest.java test/src/test/java/hudson/model/AbstractProjectTest.java core/src/main/java/hudson/tasks/ArtifactArchiver.java core/src/main/resources/hudson/tasks/ArtifactArchiver/config.properties core/src/main/resources/hudson/tasks/ArtifactArchiver/config.jelly test/src/test/java/hudson/tasks/LogRotatorTest.java Jesse Glick : e88932956f78dc8c89835256b820cca671756286 Files : changelog.html

          Code changed in jenkins
          User: Jesse Glick
          Path:
          changelog.html
          http://jenkins-ci.org/commit/jenkins/98869558a3c7b6183c60f492153b45384dd36db5
          Log:
          JENKINS-10502 This was an RFE, not a bug.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: changelog.html http://jenkins-ci.org/commit/jenkins/98869558a3c7b6183c60f492153b45384dd36db5 Log: JENKINS-10502 This was an RFE, not a bug.

          dogfood added a comment -

          Integrated in jenkins_main_trunk #2386
          JENKINS-10502 This was an RFE, not a bug. (Revision 98869558a3c7b6183c60f492153b45384dd36db5)

          Result = SUCCESS
          Jesse Glick : 98869558a3c7b6183c60f492153b45384dd36db5
          Files :

          • changelog.html

          dogfood added a comment - Integrated in jenkins_main_trunk #2386 JENKINS-10502 This was an RFE, not a bug. (Revision 98869558a3c7b6183c60f492153b45384dd36db5) Result = SUCCESS Jesse Glick : 98869558a3c7b6183c60f492153b45384dd36db5 Files : changelog.html

            nacht Pedro Rodriguez
            tfields Thomas Fields
            Votes:
            16 Vote for this issue
            Watchers:
            22 Start watching this issue

              Created:
              Updated:
              Resolved: