-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
62 lines (57 loc) · 1.85 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
pipeline {
agent any
parameters {
choice(
name: 'SuiteName',
choices: ['uiTest', 'apiTest', 'securityTest'],
description: 'Choose the TestNG suite to run the Test Cases'
)
}
stages {
stage('Clean') {
steps {
echo "Cleaning the project..."
bat "mvn clean"
}
}
stage('Build and Install') {
steps {
echo "Building and installing the project..."
bat "mvn install -DskipTests"
}
}
stage('Test') {
steps {
echo "Running test cases from Suite selected: ${params.SuiteName}"
bat "mvn test -Dsurefire.suiteXmlFiles=${params.SuiteName}.xml"
}
}
stage('Check Reports') {
steps {
echo "Checking if reports are generated..."
bat "dir target" // Lists all files in the target directory
}
}
}
post {
always {
echo 'Publishing TestNG and Extent Reports...'
publishHTML([target: [
allowMissing: true, // Change to true to avoid failure if the directory is missing
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'target/surefire-reports',
reportFiles: 'index.html',
reportName: 'TestNG Report'
]])
publishHTML([target: [
allowMissing: true, // Change to true to avoid failure if the directory is missing
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'target/extent-reports',
reportFiles: 'index.html',
reportName: 'Extent Report'
]])
}
}
}