ci: refs #8698 move functions inside script step
gitea/salix-front/pipeline/pr-dev Something is wrong with the build of this commit
Details
gitea/salix-front/pipeline/pr-dev Something is wrong with the build of this commit
Details
This commit is contained in:
parent
e1b96d6a73
commit
fcebf6f664
|
@ -9,7 +9,80 @@ def BRANCH_ENV = [
|
|||
beta: 'production'
|
||||
]
|
||||
|
||||
def getSpec(path) {
|
||||
return "test/cypress/integration/" + path.split("/")[2] + "/**/*.spec.js"
|
||||
}
|
||||
|
||||
def getSpecs() {
|
||||
return script {
|
||||
def searchFiles = { searchString ->
|
||||
def pagesPath = "src/pages"
|
||||
|
||||
def matchingFiles = sh(
|
||||
script: "grep -rl '${searchString}' ${pagesPath} || true",
|
||||
returnStdout: true
|
||||
).trim().split("\n")
|
||||
|
||||
matchingFiles = matchingFiles.findAll { it.trim() }
|
||||
def extractedFolders = matchingFiles.collect { getSpec(it) }.unique()
|
||||
extractedFolders.add(getSpec(searchString))
|
||||
|
||||
echo "Carpetas donde se encontró '${searchString}': ${extractedFolders}"
|
||||
return extractedFolders
|
||||
}
|
||||
|
||||
def lastCommit
|
||||
def lastSuccessfulBuild = currentBuild.previousBuild
|
||||
def currentCommit = sh(
|
||||
script: "git rev-parse HEAD",
|
||||
returnStdout: true
|
||||
).trim()
|
||||
def files = []
|
||||
|
||||
while (lastSuccessfulBuild != null && lastSuccessfulBuild.result != 'SUCCESS') {
|
||||
lastSuccessfulBuild = lastSuccessfulBuild.previousBuild
|
||||
}
|
||||
if (lastSuccessfulBuild != null && lastSuccessfulBuild.changeSets.size() > 0) {
|
||||
for (changeSet in lastSuccessfulBuild.changeSets) {
|
||||
for (change in changeSet.items) {
|
||||
lastCommit = change.commitId
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (lastCommit) {
|
||||
echo "Último commit exitoso: ${lastCommit}"
|
||||
}
|
||||
}
|
||||
|
||||
if(!lastCommit) {
|
||||
lastCommit = sh(script: "git rev-parse origin/${env.CHANGE_TARGET}}", returnStdout: true).trim()
|
||||
echo "Hash obtenido con git: ${lastCommit}"
|
||||
}
|
||||
|
||||
|
||||
def modifiedFiles = sh(
|
||||
script: "git diff --name-only ${lastCommit} ${currentCommit}",
|
||||
returnStdout: true
|
||||
).trim().split("\n")
|
||||
|
||||
modifiedFiles.each { file ->
|
||||
echo "- ${file}"
|
||||
if(!file.startsWith('src/pages')){
|
||||
if(file.startsWith('test/cypress/integration')){
|
||||
files.add(file)
|
||||
}
|
||||
//else {
|
||||
// files = 'test/cypress/integration/**/*.spec.js'
|
||||
// return
|
||||
// }
|
||||
} else{
|
||||
files = (files + searchFiles(file)).unique()
|
||||
}
|
||||
}
|
||||
return files
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -122,79 +195,6 @@ pipeline {
|
|||
def image = docker.build('lilium-dev', '-f docs/Dockerfile.dev docs')
|
||||
sh "docker-compose ${env.COMPOSE_PARAMS} up -d"
|
||||
|
||||
def searchFiles = { searchString ->
|
||||
def pagesPath = "src/pages"
|
||||
|
||||
def matchingFiles = sh(
|
||||
script: "grep -rl '${searchString}' ${pagesPath} || true",
|
||||
returnStdout: true
|
||||
).trim().split("\n")
|
||||
|
||||
matchingFiles = matchingFiles.findAll { it.trim() }
|
||||
def extractedFolders = matchingFiles.collect { getSpec(it) }.unique()
|
||||
extractedFolders.add(getSpec(searchString))
|
||||
|
||||
echo "Carpetas donde se encontró '${searchString}': ${extractedFolders}"
|
||||
return extractedFolders
|
||||
}
|
||||
|
||||
def getSpec(path) {
|
||||
return "test/cypress/integration/" + path.split("/")[2] + "/**/*.spec.js"
|
||||
}
|
||||
|
||||
def getSpecs() {
|
||||
def lastCommit
|
||||
def lastSuccessfulBuild = currentBuild.previousBuild
|
||||
def currentCommit = sh(
|
||||
script: "git rev-parse HEAD",
|
||||
returnStdout: true
|
||||
).trim()
|
||||
def files = []
|
||||
|
||||
while (lastSuccessfulBuild != null && lastSuccessfulBuild.result != 'SUCCESS') {
|
||||
lastSuccessfulBuild = lastSuccessfulBuild.previousBuild
|
||||
}
|
||||
if (lastSuccessfulBuild != null && lastSuccessfulBuild.changeSets.size() > 0) {
|
||||
for (changeSet in lastSuccessfulBuild.changeSets) {
|
||||
for (change in changeSet.items) {
|
||||
lastCommit = change.commitId
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (lastCommit) {
|
||||
echo "Último commit exitoso: ${lastCommit}"
|
||||
}
|
||||
}
|
||||
|
||||
if(!lastCommit) {
|
||||
lastCommit = sh(script: "git rev-parse origin/${env.CHANGE_TARGET}}", returnStdout: true).trim()
|
||||
echo "Hash obtenido con git: ${lastCommit}"
|
||||
}
|
||||
|
||||
|
||||
def modifiedFiles = sh(
|
||||
script: "git diff --name-only ${lastCommit} ${currentCommit}",
|
||||
returnStdout: true
|
||||
).trim().split("\n")
|
||||
|
||||
modifiedFiles.each { file ->
|
||||
echo "- ${file}"
|
||||
if(!file.startsWith('src/pages')){
|
||||
if(file.startsWith('test/cypress/integration')){
|
||||
files.add(file)
|
||||
}
|
||||
//else {
|
||||
// files = 'test/cypress/integration/**/*.spec.js'
|
||||
// return
|
||||
// }
|
||||
} else{
|
||||
files = (files + searchFiles(file)).unique()
|
||||
}
|
||||
}
|
||||
return files
|
||||
}
|
||||
|
||||
def specs = getSpecs()
|
||||
image.inside("--network ${env.COMPOSE_PROJECT}_default -e CI -e TZ") {
|
||||
sh "cypress run --browser chromium --spec ${specs} || true"
|
||||
|
|
Loading…
Reference in New Issue