-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
133 lines (130 loc) · 5.96 KB
/
Jenkinsfile
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
pipeline {
agent any
options {
buildDiscarder(
logRotator(
numToKeepStr: '5'
)
)
}
parameters{
string(name: 'Url', defaultValue: 'https://opensource-demo.orangehrmlive.com/', description: 'URL of the environment to be tested')
string(name: 'Env', defaultValue: 'Production', description: 'Environment name')
string(name: 'TesterName', defaultValue: 'QA Test User', description: 'Name of the tester who is running the test.')
choice(choices: ['no', 'yes'], name: 'DownloadWebDriver', description: 'Do you want the web drivers to be download automatically?')
choice(choices: ['grid', 'selenoid', 'local', 'zalenium'], name: 'RunMode', description: 'Perform execution on')
string(name: 'RemoteUrl', defaultValue: 'http://192.168.0.142:4444/wd/hub/', description: 'Url of the remote environment. Required if RunMode is Yes')
choice(choices: ['yes', 'no'], name: 'UseElk', description: 'Is Real-Time Dashboard ELK is setup?')
string(name: 'ElasticSearchUrl', defaultValue: 'http://192.168.0.142:9200/automation/result', description: 'If ELK is ready to use then provide the URL of the elastic search.')
choice(choices: ['yes', 'no'], name: 'DeleteReports', description: 'Do you want to delete reports?')
string(name: 'NumberOfDays', defaultValue: '10', description: 'The number of days older report needs to be deleted')
choice(choices: ['no', 'yes'], name: 'OverRideReports', description: 'Append in the existing report?')
choice(choices: ['yes', 'no'], name: 'TakeScreenShotForPass', description: 'Do you want to attach the screenshot to pass test cases?')
choice(choices: ['no', 'yes'], name: 'RetryFailedTestCase', description: 'Retry for failed test cases. NOT RECOMMENDED.')
choice(choices: ['no', 'yes'], name: 'SendMailAfterExecution', description: 'Do you want to send the report by email?')
choice(choices: ['outlook', 'gmail'], name: 'MailServerName', description: 'Public mail server name')
string(name: 'SenderEmailID', defaultValue: '[email protected]', description: 'Sender\'s email ID')
string(name: 'SenderPassword', defaultValue: 'MzYzMDExNTJzU0BACg==', description: 'Sender\'s email password')
string(name: 'ReceiverMailID', defaultValue: '[email protected]', description: 'Receiver\'s email ID')
}
tools {
maven 'Maven' // Name from the Jenkins Global Configuration
jdk 'Java8' // Name from the Jenkins Global Configuration
}
stages {
// Un-comment below line to give custom build name
// stage('Job description') {
// steps {
// script {
// currentBuild.displayName = "Automation-Framework-Using-JenkinsFile-Pipeline"
// currentBuild.description = "Job to execute test using jenkins file"
// }
// }
// }
stage('Clean workspace') {
steps {
cleanWs()
checkout scm
}
}
stage('Checking Mandatory Fields') {
steps {
script{
if (params.SendMailAfterExecution == 'yes') {
if(params.SenderEmailID.isEmpty()) {
currentBuild.result = 'ABORTED'
error("Sender emailID is empty")
}
if(params.SenderPassword.isEmpty()) {
currentBuild.result = 'ABORTED'
error("Sender Password is empty")
}
if(params.ReceiverMailID.isEmpty()) {
currentBuild.result = 'ABORTED'
error("Receiver emailID is empty")
}
}
if (params.Url.isEmpty()) {
currentBuild.result = 'ABORTED'
error("Url is empty")
}
if (params.Env.isEmpty()) {
currentBuild.result = 'ABORTED'
error("Env is empty")
}
if (params.TesterName.isEmpty()) {
currentBuild.result = 'ABORTED'
error("Tester name is empty")
}
if (params.RunMode == 'grid' || params.RunMode == 'selenoid') {
if (params.RemoteUrl.isEmpty()) {
currentBuild.result = 'ABORTED'
error("Remote url is empty")
}
}
if (params.UseElk == 'yes') {
if (params.ElasticSearchUrl.isEmpty()) {
currentBuild.result = 'ABORTED'
error("Elastic Search url is empty")
}
}
}
}
}
stage('Preparing Properties File') {
steps {
sh '''
chmod +x src/test/resources/Jenkins/SetupExecution.sh
./src/test/resources/Jenkins/SetupExecution.sh
'''
}
}
stage('Selenium Grid Setup') {
steps {
echo 'Hello Selenium'
}
}
stage('Selenoid Setup') {
steps {
echo 'Hello Selenoid'
}
}
stage('Starting Execution') {
steps {
sh('mvn clean compile test')
}
}
}
post {
always {
publishHTML([
allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'test-reports',
reportFiles: '*.html',
reportName: 'Test Execution Report',
reportTitles: ''])
}
}
}