ci: refs #8698 try lastSuccessfulBuild
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
5c627dd489
commit
b51f99f5f1
|
@ -10,20 +10,17 @@ def BRANCH_ENV = [
|
|||
]
|
||||
|
||||
def searchFiles = { searchString ->
|
||||
def searchPath = "src/pages"
|
||||
def pagesPath = "src/pages"
|
||||
|
||||
// Buscar en todos los archivos .vue dentro de src/pages
|
||||
def matchingFiles = sh(
|
||||
script: "grep -rl '${searchString}' ${searchPath} || true",
|
||||
script: "grep -rl '${searchString}' ${pagesPath} || true",
|
||||
returnStdout: true
|
||||
).trim().split("\n")
|
||||
|
||||
// Filtrar por si la salida está vacía
|
||||
matchingFiles = matchingFiles.findAll { it.trim() }
|
||||
|
||||
// Extraer solo el tercer segmento del path
|
||||
def extractedFolders = matchingFiles.collect { getSpec(it) }.unique()
|
||||
extractedFolders.add(getSpec(searchString))
|
||||
|
||||
echo "Carpetas donde se encontró '${searchString}': ${extractedFolders}"
|
||||
return extractedFolders
|
||||
}
|
||||
|
@ -32,7 +29,6 @@ def getSpec(path) {
|
|||
return "test/cypress/integration/" + path.split("/")[2] + "/**/*.spec.js"
|
||||
}
|
||||
|
||||
|
||||
def getSpecs() {
|
||||
def lastCommit
|
||||
def lastSuccessfulBuild = currentBuild.previousBuild
|
||||
|
@ -161,63 +157,6 @@ pipeline {
|
|||
sh 'pnpm install --prefer-offline'
|
||||
}
|
||||
}
|
||||
stage('Buscar último build con éxito') {
|
||||
steps {
|
||||
script {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
echo "files: " + files
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Test') {
|
||||
when {
|
||||
expression { !IS_PROTECTED_BRANCH }
|
||||
|
@ -255,7 +194,7 @@ pipeline {
|
|||
def image = docker.build('lilium-dev', '-f docs/Dockerfile.dev docs')
|
||||
sh "docker-compose ${env.COMPOSE_PARAMS} up -d"
|
||||
image.inside("--network ${env.COMPOSE_PROJECT}_default -e CI -e TZ") {
|
||||
sh "cypress run --browser chromium --spec ${getFiles()} || true"
|
||||
sh "cypress run --browser chromium --spec ${getSpecs()} || true"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue