ci: refs #8698 move functions inside script step
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
d15144a98a
commit
e1b96d6a73
|
@ -9,78 +9,7 @@ def BRANCH_ENV = [
|
||||||
beta: 'production'
|
beta: 'production'
|
||||||
]
|
]
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -193,6 +122,79 @@ pipeline {
|
||||||
def image = docker.build('lilium-dev', '-f docs/Dockerfile.dev docs')
|
def image = docker.build('lilium-dev', '-f docs/Dockerfile.dev docs')
|
||||||
sh "docker-compose ${env.COMPOSE_PARAMS} up -d"
|
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()
|
def specs = getSpecs()
|
||||||
image.inside("--network ${env.COMPOSE_PROJECT}_default -e CI -e TZ") {
|
image.inside("--network ${env.COMPOSE_PROJECT}_default -e CI -e TZ") {
|
||||||
sh "cypress run --browser chromium --spec ${specs} || true"
|
sh "cypress run --browser chromium --spec ${specs} || true"
|
||||||
|
|
Loading…
Reference in New Issue