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

Cache of Global Pipeline Libraries May Fail to Be Created Until Next Expiration

XMLWordPrintable

      Environments:

      • Jenkins Version: 2.346.3
      • Plugin Version: 612.v84da_9c54906d

      Steps:

      1. Turn on cache for 'Global Pipeline Libraries' in 'Configure System' and specify a refresh interval greater than 0.
      2. Cache expiration detected, the plugin deletes the existing cache folder and creates a new empty cache folder with the name generated from some hash function.
      3. The plugin fails to fetch library from GitHub repository (e.g. the GitHub server is under maintenance).
      4. All subsequent pipelines trying to load the library from the cache folder fail with following errors. 
        Loading library some_library_name@some_tag_version
        Library some_library_name@some_tag_version is cached. Copying from home.
        ERROR: Library shared-lib expected to contain at least one of src or vars directories
        org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
        WorkflowScript: Loading libraries failed 

      By navigating to '$JENKINS_HOME/global-libraries-cache', the cache folder is there but the contents are corrupted.

      Only after next expiration, the plugin will attempt another try to refresh the cache. The situation is even worse when the refresh interval is relatively long.

      The root cause is that the plugin determines the existence of a library cache by checking the existence of the cache folder and uses the modification time of the cache folder to determine if the cache has expired, regardless of the content of the folder.

      The improvement I'd suggest is that removing the newly created cache folder if the plugin fails to fetch libraries, to let the next pipeline have the chance to re-create the cache, rather than to wait for next cache expiration.

            Unassigned Unassigned
            danielcwc wangcheng cai
            Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: