ci: refs #8698 try lastSuccessfulBuild
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
15159c1937
commit
d5486f89a5
|
@ -82,39 +82,53 @@ pipeline {
|
|||
// sh 'pnpm install --prefer-offline'
|
||||
// }
|
||||
// }
|
||||
stage('Echo?') {
|
||||
when {
|
||||
changeset "src/pages/**/*"
|
||||
}
|
||||
steps {
|
||||
echo "hola"
|
||||
}
|
||||
}
|
||||
// stage('Echo?') {
|
||||
// when {
|
||||
// changeset "src/pages/**/*"
|
||||
// }
|
||||
// steps {
|
||||
// echo "hola"
|
||||
// }
|
||||
// }
|
||||
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()
|
||||
|
||||
while (lastSuccessfulBuild != null && lastSuccessfulBuild.result != 'SUCCESS') {
|
||||
lastSuccessfulBuild = lastSuccessfulBuild.previousBuild
|
||||
}
|
||||
echo "lastSuccessfulBuild ${lastSuccessfulBuild}"
|
||||
if (lastSuccessfulBuild != null && lastSuccessfulBuild.changeSets.size() > 0) {
|
||||
echo "lastSuccessfulBuild ${lastSuccessfulBuild}"
|
||||
// Extraer el commit del build exitoso desde el changelog
|
||||
def lastCommitHash = ""
|
||||
for (changeSet in lastSuccessfulBuild.changeSets) {
|
||||
for (change in changeSet.items) {
|
||||
echo "Archivos modificados: ${change.affectedPaths}"
|
||||
echo "Commit: ${change.commitId}"
|
||||
lastCommit = change.commitId
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (lastCommitHash) {
|
||||
echo "Último commit exitoso: ${lastCommitHash}"
|
||||
if (lastCommit) {
|
||||
echo "Último commit exitoso: ${lastCommit}"
|
||||
}
|
||||
} else {
|
||||
lastCommitHash = sh(script: "git rev-parse origin/${env.CHANGE_TARGET}}", returnStdout: true).trim()
|
||||
echo "Hash obtenido con git: ${lastCommitHash}"
|
||||
}
|
||||
|
||||
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}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -213,3 +227,19 @@ pipeline {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
def searchFiles = { searchString ->
|
||||
def searchPath = "src/pages"
|
||||
|
||||
// Buscar en todos los archivos .vue dentro de src/pages
|
||||
def matchingFiles = sh(
|
||||
script: "grep -rl '${searchString}' ${searchPath} || true",
|
||||
returnStdout: true
|
||||
).trim().split("\n")
|
||||
|
||||
// Filtrar por si la salida está vacía
|
||||
matchingFiles = matchingFiles.findAll { it.trim() }
|
||||
|
||||
echo "Archivos donde se encontró '${searchString}': ${matchingFiles}"
|
||||
return matchingFiles
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue