From ab424b3d657eb46b1c65ad22d3ecbbc5e8f2aa17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E6=8C=AF=E5=AE=87?= <> Date: Fri, 7 Feb 2025 17:19:14 +0800 Subject: [PATCH] fix(caching): optimize npm and yarn installation commands to prefer offline cache usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙振宇 <> --- .../freeleaps/devops/builtins/lint/eslint/eslintrc.js | 1 - .../com/freeleaps/devops/DependenciesResolver.groovy | 10 ++-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/first-class-pipeline/resources/com/freeleaps/devops/builtins/lint/eslint/eslintrc.js b/first-class-pipeline/resources/com/freeleaps/devops/builtins/lint/eslint/eslintrc.js index 2029082f..efcb2d2b 100644 --- a/first-class-pipeline/resources/com/freeleaps/devops/builtins/lint/eslint/eslintrc.js +++ b/first-class-pipeline/resources/com/freeleaps/devops/builtins/lint/eslint/eslintrc.js @@ -1,5 +1,4 @@ module.exports = { - root: true, parser: "@typescript-eslint/parser", parserOptions: { ecmaVersion: 6, diff --git a/first-class-pipeline/src/com/freeleaps/devops/DependenciesResolver.groovy b/first-class-pipeline/src/com/freeleaps/devops/DependenciesResolver.groovy index 1f6c3b12..e7161bd5 100644 --- a/first-class-pipeline/src/com/freeleaps/devops/DependenciesResolver.groovy +++ b/first-class-pipeline/src/com/freeleaps/devops/DependenciesResolver.groovy @@ -66,10 +66,7 @@ class DependenciesResolver { if (cachingEnabled) { steps.dir(this.workspace) { steps.cache(maxCacheSize: 512, caches: [[$class: 'ArbitraryFileCache', includes: '**/*', path: '.npm-cache', cacheValidityDecidingFile: 'package-lock.json']]) { - def cacheExists = steps.fileExists('.npm-cache') - if (!cacheExists) { - steps.sh "npm install --cache .npm-cache" - } + steps.sh "npm install --cache .npm-cache --prefer-offline" } } } else { @@ -91,10 +88,7 @@ class DependenciesResolver { if (cachingEnabled) { steps.dir(this.workspace) { steps.cache(maxCacheSize: 512, caches: [[$class: 'ArbitraryFileCache', includes: '**/*', path: '.yarn-cache', cacheValidityDecidingFile: 'yarn.lock']]) { - def cacheExists = steps.fileExists('.yarn-cache') - if (!cacheExists) { - steps.sh "yarn install --cache-folder .yarn-cache" - } + steps.sh "yarn install --cache-folder .yarn-cache --prefer-offline" } } } else {