From 1975370dcf5cf4c29d67c349beaa62b613e213e5 Mon Sep 17 00:00:00 2001 From: zhenyus Date: Sat, 22 Feb 2025 23:24:43 +0800 Subject: [PATCH] fix(dependencies): update cache paths for pip, npm, and yarn installations to use dynamic naming Signed-off-by: zhenyus --- .../freeleaps/devops/DependenciesResolver.groovy | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/first-class-pipeline/src/com/freeleaps/devops/DependenciesResolver.groovy b/first-class-pipeline/src/com/freeleaps/devops/DependenciesResolver.groovy index 355d5714..8df962ca 100644 --- a/first-class-pipeline/src/com/freeleaps/devops/DependenciesResolver.groovy +++ b/first-class-pipeline/src/com/freeleaps/devops/DependenciesResolver.groovy @@ -60,8 +60,10 @@ class DependenciesResolver { if (cachingEnabled) { steps.dir(this.workspace) { - steps.cache(maxCacheSize: 512, caches: [[$class: 'ArbitraryFileCache', cacheName: "${configurations.name}-pip-cache", includes: '**/*', path: '.pip-cache', cacheValidityDecidingFile: 'requirements.txt']]) { - steps.sh "pip install --cache-dir .pip-cache -r ${requirementsFile}" + steps.cache(maxCacheSize: 512, caches: [[$class: 'ArbitraryFileCache', includes: '**/*', path: ".${configurations.name}-pip-cache", cacheValidityDecidingFile: 'requirements.txt']]) { + steps.sh "mkdir -p .${configurations.name}-pip-cache" + steps.sh "pip config set global.cache-dir '${this.workspace}/.${configurations.name}-pip-cache'" + steps.sh "pip install --cache-dir .${configurations.name}-pip-cache -r ${requirementsFile}" } } } else { @@ -82,8 +84,9 @@ class DependenciesResolver { if (cachingEnabled) { steps.dir(this.workspace) { - steps.cache(maxCacheSize: 512, caches: [[$class: 'ArbitraryFileCache', cacheName: "${configurations.name}-npm-cache", includes: '**/*', path: '.npm-cache', cacheValidityDecidingFile: 'package-lock.json']]) { - steps.sh "npm install --cache .npm-cache --prefer-offline --no-audit" + steps.cache(maxCacheSize: 512, caches: [[$class: 'ArbitraryFileCache', includes: '**/*', path: ".${configurations.name}-npm-cache", cacheValidityDecidingFile: 'package-lock.json']]) { + steps.sh "mkdir -p .${configurations.name}-npm-cache" + steps.sh "npm install --cache .${configurations.name}-npm-cache --prefer-offline --no-audit" } } } else { @@ -104,8 +107,9 @@ class DependenciesResolver { if (cachingEnabled) { steps.dir(this.workspace) { - steps.cache(maxCacheSize: 512, caches: [[$class: 'ArbitraryFileCache', includes: '**/*', cacheName: "${configurations.name}-pnpm-cache", path: '.yarn-cache', cacheValidityDecidingFile: 'yarn.lock']]) { - steps.sh "yarn install --cache-folder .yarn-cache --prefer-offline" + steps.cache(maxCacheSize: 512, caches: [[$class: 'ArbitraryFileCache', includes: '**/*', path: ".${configurations.name}-yarn-cache", cacheValidityDecidingFile: 'yarn.lock']]) { + steps.sh "mkdir -p ${configurations.name}-pnpm-cache" + steps.sh "yarn install --cache-folder ${configurations.name}-pnpm-cache --prefer-offline" } } } else {