-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJenkinsfile
More file actions
80 lines (69 loc) · 2.53 KB
/
Jenkinsfile
File metadata and controls
80 lines (69 loc) · 2.53 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
73
74
75
76
77
78
79
80
pipeline {
agent any // Run on any available agent
tools {
maven "Maven" // Install the Maven version configured as "Maven" and add it to the path.
}
environment {
PROJECT_DIR = "${workspace}" // Adjust for Windows file paths
}
stages {
stage('Checkout') {
steps {
// Checkout the Git repository to the workspace
git url: 'https://github.com/rakesh-vardan/Learn_TestAutomationFramework', branch: 'main'
}
}
stage('Verify Directory Structure') {
steps {
// Debugging: List files in the workspace to check if pom.xml exists
script {
echo "Listing files in the project directory: ${PROJECT_DIR}"
bat "dir ${PROJECT_DIR}" // Windows command to list directory contents
}
}
}
stage('Install Dependencies') {
steps {
// Run mvn clean install from the root directory of the project
dir("${PROJECT_DIR}") {
script {
echo "Running mvn clean install"
bat "mvn clean install -DskipTests" // Run Maven command on Windows
}
}
}
}
stage('Run API Tests') {
steps {
// Run the REST Assured API tests
dir("${PROJECT_DIR}") {
script {
echo "Running mvn test"
bat "mvn clean test -DsuiteXMLFile=testng.xml" // Run Maven test on Windows
}
}
}
}
}
post {
always {
// Publish the Allure report (ensure correct path)
publishHTML([
reportName: 'TestReport', // Name that will be displayed in Jenkins
reportDir: 'target', // Directory where the report is located
reportFiles: 'extent-reports.html', // Name of the HTML report file (adjust as per your actual file name)
keepAll: false, // Keep previous reports (set to 'false' to overwrite)
allowMissing: true,
alwaysLinkToLastBuild: true
])
// Clean workspace after build
cleanWs()
}
success {
echo "Tests and reports were successfully generated!"
}
failure {
echo "Tests failed. Please check the logs for details."
}
}
}