refactor: refs #8698 update Jenkinsfile to extract last successful build commit hash and improve logging
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
d755c0c8ba
commit
69f84e2fcd
|
@ -86,29 +86,25 @@ pipeline {
|
|||
steps {
|
||||
script {
|
||||
def lastSuccessfulBuild = currentBuild.previousBuild
|
||||
|
||||
while (lastSuccessfulBuild != null && lastSuccessfulBuild.result != 'SUCCESS') {
|
||||
lastSuccessfulBuild = lastSuccessfulBuild.previousBuild
|
||||
}
|
||||
|
||||
if (lastSuccessfulBuild != null) {
|
||||
echo "Último build exitoso encontrado: #${lastSuccessfulBuild.number}"
|
||||
def lastChangeSets = lastSuccessfulBuild.changesets
|
||||
if (lastSuccessfulBuild) {
|
||||
// Extraer el commit del build exitoso desde el changelog
|
||||
def lastCommitHash = ""
|
||||
lastSuccessfulBuild.changesets.each { changeSet ->
|
||||
changeSet.items.each { change ->
|
||||
lastCommitHash = change.commitId
|
||||
}
|
||||
}
|
||||
|
||||
// if (lastChangeSets.size() > 0) {
|
||||
// echo "Cambios en el último build exitoso:"
|
||||
// for (changeSet in lastChangeSets) {
|
||||
// for (change in changeSet.items) {
|
||||
// echo "Autor: ${change.author}"
|
||||
// echo "Comentario: ${change.comment}"
|
||||
// echo "Archivos modificados: ${change.affectedPaths}"
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// echo "El último build exitoso no tiene cambios registrados."
|
||||
// }
|
||||
if (lastCommitHash) {
|
||||
echo "Último commit exitoso: ${lastCommitHash}"
|
||||
}
|
||||
} else {
|
||||
echo "No se encontró ningún build exitoso previo."
|
||||
lastCommitHash = sh(script: "git rev-parse origin/${env.CHANGE_TARGET}}", returnStdout: true).trim()
|
||||
echo "Hash obtenido con git: ${lastCommitHash}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue