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

Archiving artifacts does not preserve timestamps if archived on master

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • core
    • None
    • Windows 7, Java 1.8, Jenkins 1.575
      Linux 64, Java 1.8, Jenkins 1.647

      When a build run on the master, "Archive the artifacts" doesn't preserve timestamps.
      It preserves timestamps when run on slaves.

      It looks caused by FilePath.copyRecursiveTo.


      Original description (the issue was found not of Copyartifact, but of ArtifactArchiver):

      The timestamps of artifacts are not preserved when archiving artifacts, OR performing a CopyArtifact operation if the artifact filter is set to "**".

      For example the filter

      "myfolder\**"

      will preserve timestamps.

      We use mutiple chained Jenkins jobs to perform a build. If the timestamps of dependency files in the artifact passed between jobs is not preserved, then subsequent jobs will fail.

          [JENKINS-23645] Archiving artifacts does not preserve timestamps if archived on master

          Daniel Beck added a comment -

          Makes sense. FilePath.copyRecursiveTo(DirScanner,FilePath,String) behaves differently when it's a master local copy: In that case, it simply copies the files over using IOUtils.mkdirs/Util.copyFile (which in turn uses org.apache.tools.ant.taskdefs.Copy without preservelastmodified). In the remote case, it creates a Tar archive and transfers it over the remoting channel, extracting on the master.

          Daniel Beck added a comment - Makes sense. FilePath.copyRecursiveTo(DirScanner,FilePath,String) behaves differently when it's a master local copy: In that case, it simply copies the files over using IOUtils.mkdirs/Util.copyFile (which in turn uses org.apache.tools.ant.taskdefs.Copy without preservelastmodified). In the remote case, it creates a Tar archive and transfers it over the remoting channel, extracting on the master.

          Daniel Beck added a comment -

          Seems unrelated to CopyArtifact.

          Daniel Beck added a comment - Seems unrelated to CopyArtifact.

          ikedam added a comment -

          Let me see.
          The problem happened not at "Copy artifacts from another project" in a downstream project, but at "Archive the artifacts" in a upstream project, right?

          ikedam added a comment - Let me see. The problem happened not at "Copy artifacts from another project" in a downstream project, but at "Archive the artifacts" in a upstream project, right?

          Daniel Beck added a comment -

          Presumably both, and both caused by FilePath (e.g. if upstream runs on a slave, the artifacts are okay, but downstream running on master would ruin it). Haven't tested it though, it seems without a core fix there's no real solution for CA to get it right.

          Daniel Beck added a comment - Presumably both, and both caused by FilePath (e.g. if upstream runs on a slave, the artifacts are okay, but downstream running on master would ruin it). Haven't tested it though, it seems without a core fix there's no real solution for CA to get it right.

          Timmy Brolin added a comment -

          I upgraded to Jenkins 1.575, it made no difference.

          I will try different combinations of upstream/downstream jobs running on master/slave and post the results.

          Right now the timestamps are actually incorrect regardless of the filter setting. Not sure if it is connected to the updates I did, some other change, or if the "*" filter happened to run on the master, and the "myfolder/*" filter originally happened to run on the slave without me noticing it. Can't say for sure.

          Timmy Brolin added a comment - I upgraded to Jenkins 1.575, it made no difference. I will try different combinations of upstream/downstream jobs running on master/slave and post the results. Right now the timestamps are actually incorrect regardless of the filter setting. Not sure if it is connected to the updates I did, some other change, or if the "* " filter happened to run on the master, and the "myfolder/ *" filter originally happened to run on the slave without me noticing it. Can't say for sure.

          Timmy Brolin added a comment -

          Tested on Jenkins 1.575, with java 1.8
          ---------------------------------------

          Job running on master archiving artifacts to master: Incorrect timestamps.

          Job running on slave archiving artifacts to master: Timestamps ok.

          Downstream job running on master copying artifacts from master: Timestamps ok.

          Downstream job running on slave copying artifacts from master: Timestamps ok.

          Does this make any sense?

          Timmy Brolin added a comment - Tested on Jenkins 1.575, with java 1.8 --------------------------------------- Job running on master archiving artifacts to master: Incorrect timestamps. Job running on slave archiving artifacts to master: Timestamps ok. Downstream job running on master copying artifacts from master: Timestamps ok. Downstream job running on slave copying artifacts from master: Timestamps ok. Does this make any sense?

          ikedam added a comment -

          That's exactly what @danielbeck pointed.
          Thanks for clarifying.
          I updated the summary and the description.

          I think it won't be fixed so soon, and you'd better try workarounds like:

          • Archive files with zip command in the upstream project, and extract them with unzip in the downstream project.
          • Have builds run only on slaves. This can be done by enabling "Restrict where this project can be run" in project configuration pages.

          ikedam added a comment - That's exactly what @danielbeck pointed. Thanks for clarifying. I updated the summary and the description. I think it won't be fixed so soon, and you'd better try workarounds like: Archive files with zip command in the upstream project, and extract them with unzip in the downstream project. Have builds run only on slaves. This can be done by enabling "Restrict where this project can be run" in project configuration pages.

          Daniel Beck added a comment -

          FWIW some [citation needed] consider running no builds on the master node a Jenkins best practice, so that may be worth implementing even beyond this issue.

          Daniel Beck added a comment - FWIW some [citation needed] consider running no builds on the master node a Jenkins best practice, so that may be worth implementing even beyond this issue.

          Timmy Brolin added a comment -

          Yes, preventing jobs from running on the master solves the problem.

          Timmy Brolin added a comment - Yes, preventing jobs from running on the master solves the problem.

          Olaf Lenz added a comment -

          The problem still exists in 1.647. Does this really mean that I have to run a slave on the same host where the master runs, just to be able to use the host?

          Olaf Lenz added a comment - The problem still exists in 1.647. Does this really mean that I have to run a slave on the same host where the master runs, just to be able to use the host?

            Unassigned Unassigned
            tib Timmy Brolin
            Votes:
            4 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: