-
Notifications
You must be signed in to change notification settings - Fork 34
/
ui_ci.groovy
80 lines (65 loc) · 2.88 KB
/
ui_ci.groovy
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
@Library('pipelinex@development')
import com.iguazio.pipelinex.JobException
def node_label = 'ubuntu-ui-runner'
common.set_current_display_name("UI_CI_Test")
common.main {
timestamps {
nodes.runner(node_label) {
stage('UI CI Test') {
common.conditional_stage('Pull Latest Changes', true) {
checkout scm
}
common.conditional_stage('Set up Environment', true) {
sh 'npm install'
}
common.conditional_stage('Start Services', true) {
sh '''
npm run mock-server &
npm start &
'''
}
common.conditional_stage('Run Regression Tests', true) {
// Run cucumber-js tests
sh './node_modules/.bin/cucumber-js --require-module @babel/register --require-module @babel/polyfill -f json:tests/reports/cucumber_report.json -f html:tests/reports/cucumber_report_default.html tests -t \'@smoke\''
}
common.conditional_stage('Post-Test Cleanup', true) {
sh '''
kill %1 || true
kill %2 || true
# Ensure any remaining background processes are terminated
pkill -f npm || true
'''
}
common.conditional_stage('Upload Artifacts', true) {
sh '''
# touch tests/reports/cucumber_report_default.html
# Environment variables
ART_URL="http://artifactory.iguazeng.com:8082/artifactory/ui-ci-reports"
AUTH="${ARTIFACTORY_CRED}"
LOCAL_FILE="tests/reports/cucumber_report_default.html"
# Generate the Artifactory path with the build number
ARTIFACTORY_PATH="cucumber_report_default_${BUILD_NUMBER}.html"
# Construct the full URL
URL="${ART_URL}/${ARTIFACTORY_PATH}"
# Upload the file to Artifactory
curl -X PUT -u ${AUTH} "${URL}" --data-binary @"${LOCAL_FILE}"
'''
}
common.conditional_stage('Cleaning up', true) {
sh '''
pkill -f npm || true
'''
}
common.conditional_stage('Build Status', true) {
script {
if (currentBuild.currentResult == 'SUCCESS') {
echo 'Build was successful!'
} else {
echo 'Build failed!'
}
}
}
}
}
}
}