-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
73 lines (64 loc) · 2.5 KB
/
Copy pathJenkinsfile
File metadata and controls
73 lines (64 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Jenkinsfile - declarative pipeline for the Selenium + Pytest + Allure
// framework. Written for a Windows Jenkins agent (matches the drivers/
// folder and manually installed browser binaries the framework expects).
// Tested against Jenkins 2.375.3 with the Pipeline, Git, and Allure
// Jenkins plugins installed.
pipeline {
agent any
parameters {
choice(name: 'BROWSER', choices: ['chrome', 'firefox', 'edge'],
description: 'Browser to run the tests against')
booleanParam(name: 'HEADLESS', defaultValue: true,
description: 'Run the browser in headless mode')
}
options {
timestamps()
disableConcurrentBuilds()
}
// "zoho-email-credentials" is a Jenkins "Username and password"
// credential: username = the Zoho Mail sender address, password =
// that account's SMTP (app) password. Jenkins exposes it as the two
// env vars below - the same EMAIL_SENDER / EMAIL_PASSWORD names
// utils/email_report.py reads locally, so no code differs between
// a Jenkins run and a developer's own machine.
environment {
ZOHO_CREDENTIALS = credentials('zoho-email-credentials')
EMAIL_SENDER = "${ZOHO_CREDENTIALS_USR}"
EMAIL_PASSWORD = "${ZOHO_CREDENTIALS_PSW}"
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Set Up Python Environment') {
steps {
bat 'python -m venv venv'
bat 'venv\\Scripts\\pip install --upgrade pip'
bat 'venv\\Scripts\\pip install -r requirements.txt'
}
}
stage('Run Tests') {
steps {
script {
def headlessFlag = params.HEADLESS ? '--headless' : ''
// --send-email is the exact same flag and the exact
// same utils/email_report.py code a person would use
// running pytest locally - nothing Jenkins-specific
// about the email logic itself.
bat "venv\\Scripts\\pytest --browser=${params.BROWSER} ${headlessFlag} --send-email"
}
}
}
}
post {
always {
allure includeProperties: false,
jdk: '',
results: [[path: 'reports/allure-results']]
archiveArtifacts artifacts: 'screenshots/**, logs/**',
allowEmptyArchive: true
}
}
}