diff --git a/Jenkinsfile b/Jenkinsfile index 53d6862d4..0cb21df6b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -124,29 +124,35 @@ pipeline { sh 'docker-compose -f docker-compose.e2e.yml up -d --build front' } } + stage('Build E2E') { + steps { + sh 'docker-compose -f docker-compose.e2e.yml build e2e' + } + } } } stage('Run E2E') { - steps { + steps { script { - sh 'docker-compose -f docker-compose.e2e.yml up --build e2e' - def containerId = sh(script: "docker-compose -f docker-compose.e2e.yml ps -q e2e", returnStdout: true).trim() - if (containerId) { - def exitCode = sh(script: "docker inspect -f '{{.State.ExitCode}}' ${containerId}", returnStdout: true).trim() - sh "docker cp ${containerId}:/app/test/cypress/reports ./test/cypress/" - if (exitCode != '0') { - def logs = sh(script: "docker logs ${containerId}", returnStdout: true).trim() - error("Cypress E2E tests failed with exit code: ${exitCode}\nLogs:\n${logs}") - } - } else { - error("The Docker container for E2E tests could not be created") - } + runCypressTests(['claim', 'ticket']) } } } } post { always { + sh 'docker-compose -f docker-compose.e2e.yml up --build e2e' + def containerId = sh(script: "docker-compose -f docker-compose.e2e.yml ps -q e2e", returnStdout: true).trim() + if (containerId) { + def exitCode = sh(script: "docker inspect -f '{{.State.ExitCode}}' ${containerId}", returnStdout: true).trim() + sh "docker cp ${containerId}:/app/test/cypress/reports ./test/cypress/" + if (exitCode != '0') { + def logs = sh(script: "docker logs ${containerId}", returnStdout: true).trim() + error("Cypress E2E tests failed with exit code: ${exitCode}\nLogs:\n${logs}") + } + } else { + error("The Docker container for E2E tests could not be created") + } cleanDockerE2E() } } @@ -195,3 +201,21 @@ def cleanDockerE2E() { sh 'docker-compose -f docker-compose.e2e.yml down || true' } } + +def runCypressTests(folders) { + script { + def parallelStages = [:] + folders.each { folder -> + parallelStages["E2E - ${folder}"] = { + stage("E2E - ${folder}") { + steps { + script { + sh "docker-compose run e2e npx cypress run --config specPattern=test/cypress/integration/${folder}/**/*.spec.js" + } + } + } + } + } + parallel parallelStages + } +} diff --git a/cypress.config.js b/cypress.config.js index 96df785a2..ee14c3733 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -37,12 +37,6 @@ export default defineConfig({ setupNodeEvents: async (on, config) => { const plugin = await import('cypress-mochawesome-reporter/plugin'); plugin.default(on); - // if (process.env.JENKINS_URL) { - // on('fail', (error) => { - // // Detener la ejecuciĆ³n en caso de fallo solo en Jenkins - // throw new Error(error.message); - // }); - // } return config; }, viewportWidth: 1280,