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

FilePath.installIfNecessaryFrom always download even if target already exists

    Details

    • Similar Issues:

      Description

      FilePath.installIfNecessaryFrom, used from ZipExtractionInstaller, is designed to check if target already exists before downloading from remote URL. 

      But I observe that every time I run the build job, the tool is downloaded from remote URL even if the files exists in local $JENKINS_HOME/tools directory.

      No exception raised while processing.

       
      Simple test pipeline to reproduce issue:

      pipeline {
          agent any
          
          tools {
      		maven "M3"
      		jdk "JDK8_161"
      	}
      
          stages {
              stage('Test') {
                  steps {
                      echo 'Testing..'
                  }
              }
          }
      }
      

      *Job output logs for this example *:

      [Pipeline] node
      Running on Jenkins in /var/jenkins_home/workspace/test
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (Declarative: Tool Install)
      [Pipeline] tool
      [Pipeline] envVarsForTool
      [Pipeline] tool
      Unpacking https://<repo>.box.com/shared/static/rczslq4dc79l3ylhuoxhlje4kiu2iu7o.gz to /var/jenkins_home/tools/hudson.model.JDK/JDK8_161 on Jenkins
      [Pipeline] envVarsForTool
      Unpacking https://<repo>.box.com/shared/static/rczslq4dc79l3ylhuoxhlje4kiu2iu7o.gz
      to /var/jenkins_home/tools/hudson.model.JDK/JDK8_161 on Jenkins
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] withEnv
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (Test)
      [Pipeline] tool
      [Pipeline] envVarsForTool
      [Pipeline] tool
      Unpacking https://<repo>.box.com/shared/static/rczslq4dc79l3ylhuoxhlje4kiu2iu7o.gz
      to /var/jenkins_home/tools/hudson.model.JDK/JDK8_161 on Jenkins
      [Pipeline] envVarsForTool
      Unpacking https://<repo>.box.com/shared/static/rczslq4dc79l3ylhuoxhlje4kiu2iu7o.gz
      to /var/jenkins_home/tools/hudson.model.JDK/JDK8_161 on Jenkins
      [Pipeline] withEnv
      [Pipeline] {
      [Pipeline] echo
      Testing..
      [Pipeline] }
      [Pipeline] // withEnv
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // withEnv
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      Finished: SUCCESS

      Tools auto-installer configuration :

      We can see that M3 is not downloaded because it's already existing in $JENKINS_HOME/tools
      But JDK8_161 is downloaded every time I run the job.

        Attachments

          Activity

          Hide
          cyril_shcnei Cyril MARIN added a comment -

          A little précision :

          My tools are hosted on a Box.com repository with a public static URL.

          Maybe there is a trouble with Box hosting. Http headers may not contain "last-modified" for some reason.

           

          Show
          cyril_shcnei Cyril MARIN added a comment - A little précision : My tools are hosted on a Box.com repository with a public static URL. Maybe there is a trouble with Box hosting. Http headers may not contain "last-modified" for some reason.  
          Hide
          charanbir C R added a comment -

          Hi Cyril MARIN

          I looked at the code and you're right. The "last-modified" http header is missing.

          Now, we could add a condition to check if the "file exists locally and http header missing" then skip download, but this is wrong because if the remote file is updated, Jenkins will not download the fresh copy and assume we already have the updated copy.

          So I think this issue should be closed since the problem lies outside Jenkins.

          Show
          charanbir C R added a comment - Hi Cyril MARIN I looked at the code and you're right. The "last-modified" http header is missing. Now, we could add a condition to check if the "file exists locally and http header missing" then skip download, but this is wrong because if the remote file is updated, Jenkins will not download the fresh copy and assume we already have the updated copy. So I think this issue should be closed since the problem lies outside Jenkins.

            People

            • Assignee:
              Unassigned
              Reporter:
              cyril_shcnei Cyril MARIN
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: