diff --git a/Jenkinsfile b/Jenkinsfile index af9c084b66..442b3206e3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -93,18 +93,16 @@ pipeline { NODE_ENV = "" CREDENTIALS = credentials('docker-registry') } - stages { - stage('Setup') { - steps { - script { - def packageJson = readJSON file: 'package.json' - env.VERSION = "${packageJson.version}-build${env.BUILD_ID}" - cleanDockerE2E() - } - sh 'rm -rf salix' - sh 'git clone https://gitea.verdnatura.es/verdnatura/salix.git' - } + steps { + script { + def packageJson = readJSON file: 'package.json' + env.VERSION = "${packageJson.version}-build${env.BUILD_ID}" + cleanDockerE2E() } + sh 'rm -rf salix' + sh 'git clone https://gitea.verdnatura.es/verdnatura/salix.git' + } + stages { stage('Up') { parallel{ stage('Database') { @@ -127,17 +125,28 @@ pipeline { } stage('Run E2E') { steps { - sh 'docker-compose -f docker-compose.e2e.yml up e2e' + script { + sh 'docker-compose -f docker-compose.e2e.yml up e2e' + def result = sh(script: 'docker-compose -f docker-compose.e2e.yml ps -q e2e | xargs docker inspect -f "{{.State.ExitCode}}"', returnStatus: true) + sh 'docker cp $(docker-compose -f docker-compose.e2e.yml ps -q e2e):/app/test/cypress/reports ./test/cypress/' + if (result != 0) { + error("Cypress E2E tests failed with exit code: ${result}") + } + } } } } post { always { + publishHTML([ + allowMissing: true, + alwaysLinkToLastBuild: true, + keepAll: true, + reportDir: 'test/cypress/reports', + reportFiles: '*.html', + reportName: 'Cypress Mochawesome Report' + ]) cleanDockerE2E() - junit( - testResults: 'junitresults.xml', - allowEmptyResults: true - ) } } } diff --git a/cypress.config.js b/cypress.config.js index 559c0571eb..ba30a50f35 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -24,6 +24,7 @@ export default defineConfig({ embeddedScreenshots: true, reportDir: 'test/cypress/reports', inlineAssets: true, + json: true, }, component: { componentFolder: 'src', @@ -33,7 +34,6 @@ export default defineConfig({ setupNodeEvents: async (on, config) => { const plugin = await import('cypress-mochawesome-reporter/plugin'); plugin.default(on); - return config; }, viewportWidth: 1280, diff --git a/docker-compose.e2e.yml b/docker-compose.e2e.yml index f9b56e5df7..79b83b824f 100644 --- a/docker-compose.e2e.yml +++ b/docker-compose.e2e.yml @@ -7,7 +7,7 @@ services: dockerfile: ./Dockerfile.e2e network_mode: host e2e: - command: npx cypress run --reporter junit --reporter-options "mochaFile=junitresults.xml" + command: npx cypress run build: context: . dockerfile: ./Dockerfile.e2e