fix(caching): add logging for cache restoration in npm and yarn installations

Signed-off-by: 孙振宇 <>
This commit is contained in:
孙振宇 2025-02-07 17:13:33 +08:00
parent 6810be5cd8
commit d6e3008c6e

View File

@ -65,7 +65,9 @@ class DependenciesResolver {
if (cachingEnabled) { if (cachingEnabled) {
steps.dir(this.workspace) { steps.dir(this.workspace) {
steps.cache(maxCacheSize: 512, caches: [[$class: 'ArbitraryFileCache', includes: '**/*', path: '.npm-cache', cacheValidityDecidingFile: 'package-lock.json']]) steps.cache(maxCacheSize: 512, caches: [[$class: 'ArbitraryFileCache', includes: '**/*', path: '.npm-cache', cacheValidityDecidingFile: 'package-lock.json']]) {
steps.log.info("Dependencies Resolver","Caches are restored")
}
def cacheExists = steps.fileExists('.npm-cache') def cacheExists = steps.fileExists('.npm-cache')
if (!cacheExists) { if (!cacheExists) {
steps.sh "npm install --cache .npm-cache" steps.sh "npm install --cache .npm-cache"
@ -89,7 +91,9 @@ class DependenciesResolver {
if (cachingEnabled) { if (cachingEnabled) {
steps.dir(this.workspace) { steps.dir(this.workspace) {
steps.cache(maxCacheSize: 512, caches: [[$class: 'ArbitraryFileCache', includes: '**/*', path: '.yarn-cache', cacheValidityDecidingFile: 'yarn.lock']]) steps.cache(maxCacheSize: 512, caches: [[$class: 'ArbitraryFileCache', includes: '**/*', path: '.yarn-cache', cacheValidityDecidingFile: 'yarn.lock']]) {
steps.log.info("Dependencies Resolver","Caches are restored")
}
def cacheExists = steps.fileExists('.yarn-cache') def cacheExists = steps.fileExists('.yarn-cache')
if (!cacheExists) { if (!cacheExists) {
steps.sh "yarn install --cache-folder .yarn-cache" steps.sh "yarn install --cache-folder .yarn-cache"