-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
60 lines (45 loc) · 1.99 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
pipeline {
agent any
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Execute Tests') {
steps {
script {
// Tests run
def mvnResult = bat(script: 'mvn verify -Dcucumber.options="--tags=$env.TAGS"', returnStatus: true)
// Test result evaluation
isBuildSuccess = mvnResult == 0
}
}
}
stage('Send Report') {
steps {
script {
def htmlFiles = findFiles(glob: '**/target/cucumber-html-reports/*.html')
def firstHtmlFile = null
if (htmlFiles.length == 0) {
error('Hata: Belirtilen konumda HTML dosyası bulunamadı.')
} else {
firstHtmlFile = htmlFiles.first()
}
def screenshotFiles = findFiles(glob: '**/target/Screenshots/*.png')
def screenshotPaths = screenshotFiles.collect { file -> file.path }
def emailSubject = isBuildSuccess ? "Cucumber Test Report - Successful (${env.BUILD_NUMBER})" :
"Cucumber Test Report - Failed (${env.BUILD_NUMBER})"
def emailBody = isBuildSuccess ? "Hello,\n\nCucumber tests successful completed. Report link: \n${firstHtmlFile.path}\n \n${screenshotPaths.join('\n')}\n \nBest Regards,\nJenkins" :
"Hello,\n\nCucumber tests Failed. Report link: \n${firstHtmlFile.path}\n \n${screenshotPaths.join('\n')}\n \nBest Regards,\nJenkins"
mail to :'35test42@gmail.com',
subject : emailSubject,
body : emailBody
}
}
}
}
triggers {
cron('0 8 * * *')
}
}