Does Jenkins Pipeline CPS cache invalidate on shared library update without restart?
0 reputation · 30 Sept 2024, 01:25 UTC
Jenkins compiles and caches Groovy scripts from Pipeline definitions and shared libraries to avoid re-parsing on each build. The cache is stored under $JENKINS_HOME/caches and is used by the Pipeline CPS plugin.
The documented control for this behavior is the system property org.jenkinsci.plugins.workflow.cps.CpsThreadFactory.disableCache, which can turn caching off. There is no built-in mechanism documented to detect file-system changes and purge the cache dynamically. Community discussion around JENKINS-45071 highlights stale-cache concerns, with no consensus on whether Jenkins should adopt automatic cache invalidation or leave responsibility to administrators.
The goal is to clarify the expected invalidation semantics for Pipeline Groovy script caching.
Does the Pipeline CPS cache consider file modification time or checksum when loading a script? Which conditions, if any, cause the cache to be cleared automatically besides instance restart or Reload Configuration from Disk? Is there an official stance on automatic cache invalidation for shared libraries?