refactor(ChangedComponentsDetector, CommitMessageLinter, DependenciesResolver, executeFreeleapsPipeline): standardize workspace handling in directory operations
Signed-off-by: 孙振宇 <>
This commit is contained in:
parent
adfc71ea22
commit
376fa19c78
@ -11,7 +11,7 @@ class ChangedComponentsDetector {
|
||||
def detect(workspace, components) {
|
||||
def changedComponents = [] as Set
|
||||
|
||||
dir(workspace) {
|
||||
steps.dir(workspace) {
|
||||
// using git command to get changed files list
|
||||
def changedFiles = sh(script: 'git diff --name-only HEAD~1 HEAD', returnStdout: true)
|
||||
.trim()
|
||||
|
||||
@ -23,6 +23,8 @@ class CommitMessageLinter {
|
||||
|
||||
steps.log.info "Linting commit messages from HEAD..."
|
||||
|
||||
steps.sh "commitlint --verbose -g ${rules} -f HEAD^"
|
||||
steps.dir(steps.env.workspace) {
|
||||
steps.sh "commitlint --verbose -g ${rules} -f HEAD^"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -53,11 +53,15 @@ class DependenciesResolver {
|
||||
def packageJsonFile = configurations.npmPackageJsonFile
|
||||
|
||||
if (cachingEnabled) {
|
||||
steps.cache(maxCacheSize: 512, caches: [[$class: 'ArbitraryFileCache', excludes: '', includes: '**/*', path: '.npm-cache']]) {
|
||||
steps.sh "npm install --cache .npm-cache"
|
||||
steps.dir(steps.env.workspace) {
|
||||
steps.cache(maxCacheSize: 512, caches: [[$class: 'ArbitraryFileCache', excludes: '', includes: '**/*', path: '.npm-cache']]) {
|
||||
steps.sh "npm install --cache .npm-cache"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
steps.sh "npm install"
|
||||
steps.dir(steps.env.workspace) {
|
||||
steps.sh "npm install"
|
||||
}
|
||||
}
|
||||
|
||||
break
|
||||
@ -69,11 +73,15 @@ class DependenciesResolver {
|
||||
def packageJsonFile = configurations.yarnPackageJsonFile
|
||||
|
||||
if (cachingEnabled) {
|
||||
steps.cache(maxCacheSize: 512, caches: [[$class: 'ArbitraryFileCache', excludes: '', includes: '**/*', path: '.yarn-cache']]) {
|
||||
steps.sh "yarn install --cache-folder .yarn-cache"
|
||||
steps.dir(steps.env.workspace) {
|
||||
steps.cache(maxCacheSize: 512, caches: [[$class: 'ArbitraryFileCache', excludes: '', includes: '**/*', path: '.yarn-cache']]) {
|
||||
steps.sh "yarn install --cache-folder .yarn-cache"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
steps.sh "yarn install"
|
||||
steps.dir(steps.env.workspace) {
|
||||
steps.sh "yarn install"
|
||||
}
|
||||
}
|
||||
|
||||
break
|
||||
|
||||
@ -185,6 +185,7 @@ spec:
|
||||
dependenciesResolver.disableCachingSupport()
|
||||
}
|
||||
|
||||
sourceFetcher.fetch(configurations)
|
||||
dependenciesResolver.resolve(configurations)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user