11pipeline {
22 agent any
3-
4- environment {
5- NODE_VERSION = ' 18'
6- TEST_ENV = ' QA'
7- PLAYWRIGHT_BROWSERS_PATH = " ${ WORKSPACE} \\ ms-playwright"
8- }
9-
3+
104 parameters {
11- choice(name : ' BROWSER' , choices : [' chromium-ui' , ' firefox-ui' , ' webkit-ui' , ' api-tests' , ' all' ], description : ' Selecciona el navegador o tipo de test' )
12- choice(name : ' TEST_SUITE' , choices : [' all' , ' ui' , ' api' , ' e2e' , ' integration' , ' contract' , ' performance' , ' security' , ' accessibility' , ' visual' ], description : ' Selecciona la suite de tests' )
13- booleanParam(name : ' HEADED' , defaultValue : false , description : ' Ejecutar tests con interfaz gráfica' )
14- booleanParam(name : ' UPDATE_SNAPSHOTS' , defaultValue : false , description : ' Actualizar screenshots base' )
15- }
16-
17- triggers {
18- cron(' 0 2 * * *' )
19- githubPush()
5+ choice(name : ' BROWSER' , choices : [' chromium-ui' , ' firefox-ui' , ' webkit-ui' , ' all' ], description : ' Navegador' )
6+ choice(name : ' TEST_SUITE' , choices : [' all' , ' ui' , ' api' , ' e2e' ], description : ' Suite de tests' )
207 }
218
229 stages {
23- stage(' 🔍 Checkout' ) {
10+ stage(' Checkout' ) {
2411 steps {
25- echo ' === Clonando repositorio desde GitHub ==='
26- checkout scm
12+ echo ' === Clonando repositorio ==='
13+ git branch : ' main ' , url : ' https://github.com/ipanaque94/playwright-professional-framework.git '
2714 }
2815 }
2916
30- stage(' 📦 Install Dependencies ' ) {
17+ stage(' Install' ) {
3118 steps {
32- echo ' === Instalando dependencias de Node.js ==='
19+ echo ' === Instalando dependencias ==='
3320 bat '''
34- node --version
35- npm --version
3621 npm ci
37- '''
38- }
39- }
40-
41- stage(' 🎭 Install Playwright Browsers' ) {
42- steps {
43- echo ' === Instalando navegadores de Playwright ==='
44- bat '''
4522 npx playwright install --with-deps
4623 '''
4724 }
4825 }
4926
50- stage(' 🧪 Run Non-Visual Tests' ) {
51- steps {
52- echo ' === Ejecutando tests (sin visuales) ==='
53- bat '''
54- npx playwright test --grep-invert "VIS"
55- '''
56- }
57- }
58-
59- stage(' 📸 Generate Visual Snapshots' ) {
60- steps {
61- echo ' === Generando snapshots visuales ==='
62- bat '''
63- npx playwright test tests/visual/ --update-snapshots
64- '''
65- }
66- }
67-
68- stage(' ✅ Run All Tests' ) {
27+ stage(' Test' ) {
6928 steps {
29+ echo ' === Ejecutando tests ==='
7030 script {
71- echo ' === Ejecutando suite completa de tests ==='
72-
73- def testCommand = buildTestCommand(
74- params. TEST_SUITE ,
75- params. BROWSER ,
76- params. HEADED ,
77- params. UPDATE_SNAPSHOTS
78- )
79-
80- echo " Comando: ${ testCommand} "
31+ def testCommand = ' npx playwright test'
8132
82- def testResult = bat(
83- script : testCommand,
84- returnStatus : true
85- )
86-
87- env. TEST_RESULT = testResult
33+ if (params. TEST_SUITE != ' all' ) {
34+ testCommand + = " tests/${ params.TEST_SUITE} /"
35+ }
8836
89- if (testResult != 0 ) {
90- echo ' ⚠️ Algunos tests fallaron'
91- unstable(message : " Tests fallaron" )
92- } else {
93- echo ' ✅ Todos los tests pasaron'
37+ if (params. BROWSER != ' all' ) {
38+ testCommand + = " --project=${ params.BROWSER} "
9439 }
40+
41+ bat(script : testCommand, returnStatus : true )
9542 }
9643 }
9744 }
9845
99- stage(' 📊 Generate Reports ' ) {
46+ stage(' Report ' ) {
10047 steps {
101- echo ' === Generando reportes HTML ==='
102- bat '''
103- if exist reports\\ html-report (echo Reporte HTML generado) else (echo No se generó reporte)
104- '''
105- }
106- }
107-
108- stage(' 📸 Archive Artifacts' ) {
109- steps {
110- echo ' === Archivando artefactos ==='
111-
48+ echo ' === Publicando reportes ==='
11249 publishHTML([
11350 allowMissing : true ,
11451 alwaysLinkToLastBuild : true ,
11552 keepAll : true ,
11653 reportDir : ' reports/html-report' ,
11754 reportFiles : ' index.html' ,
118- reportName : ' Playwright Test Report' ,
119- reportTitles : ' Test Report'
55+ reportName : ' Test Report'
12056 ])
121-
122- archiveArtifacts(
123- artifacts : ' test-results/**/*,screenshots/**/*' ,
124- allowEmptyArchive : true ,
125- fingerprint : true
126- )
127- }
128- }
129-
130- stage(' 📈 Publish Test Results' ) {
131- steps {
132- echo ' === Publicando resultados JUnit ==='
133-
134- junit(
135- testResults : ' reports/junit-results.xml' ,
136- allowEmptyResults : true ,
137- skipPublishingChecks : false
138- )
13957 }
14058 }
14159 }
142-
60+
14361 post {
14462 always {
145- echo ' === Pipeline terminado === '
63+ echo ' Pipeline terminado'
14664 }
147-
14865 success {
149- echo ' ✅ Pipeline completado con éxito!'
150- script {
151- echo " Tests completados en: ${ currentBuild.durationString} "
152- }
66+ echo ' ✅ Pipeline exitoso'
15367 }
154-
15568 failure {
156- echo ' ❌ El pipeline falló'
157- script {
158- if (env. TEST_RESULT != ' 0' ) {
159- echo ' Los tests fallaron. Revisa el reporte HTML.'
160- }
161- }
162- }
163-
164- unstable {
165- echo ' ⚠️ Pipeline inestable - algunos tests fallaron'
69+ echo ' ❌ Pipeline falló'
16670 }
16771 }
168- }
169-
170- def buildTestCommand (testSuite , browser , headed , updateSnapshots ) {
171- def command = ' npx playwright test'
172-
173- if (testSuite != ' all' ) {
174- command + = " tests/${ testSuite} /"
175- }
176-
177- if (browser != ' all' ) {
178- command + = " --project=${ browser} "
179- }
180-
181- if (headed) {
182- command + = ' --headed'
183- }
184-
185- if (updateSnapshots) {
186- command + = ' --update-snapshots'
187- }
188-
189- return command
19072}
0 commit comments