-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathJenkinsfile_mlm_51_ai_acceptance_tests
More file actions
137 lines (123 loc) · 4.74 KB
/
Jenkinsfile_mlm_51_ai_acceptance_tests
File metadata and controls
137 lines (123 loc) · 4.74 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
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
134
135
136
137
pipeline {
agent {
label 'sumaform-cucumber'
}
options {
// Keeps the console clean and adds timestamps
timestamps()
// Prevents the job from hanging forever if SSH or Docker operations hang
timeout(time: 30, unit: 'MINUTES')
}
parameters {
string(
name: 'MCP_SERVER_BRANCH',
defaultValue: 'main',
description: 'The branch to check out from the mcp-server-uyuni repository.'
)
}
triggers {
// Poll the SCM every five minutes for changes.
// 'H' is used to spread out the load on Jenkins.
// This requires the Jenkins job to be configured to point to the mcp-server-uyuni git repository.
pollSCM('H/5 * * * *')
}
environment {
// Sanitize JOB_NAME for Docker compatibility (lowercase, no illegal chars)
DOCKER_TAG = "${env.JOB_NAME.toLowerCase().replaceAll(/[^a-z0-9]/, '-')}"
}
stages {
stage('Revert Snapshot') {
steps {
echo 'Reverting environment to clean state...'
sh 'ssh -o BatchMode=yes -o StrictHostKeyChecking=accept-new -o ConnectTimeout=10 root@suma-09.mgr.suse.de revert-last-snapshot-env.sh mlm-test-ai'
}
}
stage('Checkout Code') {
steps {
echo 'Checking out mcp-server-uyuni...'
git url: 'https://github.com/uyuni-project/mcp-server-uyuni.git', branch: params.MCP_SERVER_BRANCH
}
}
stage('Build Test Image') {
steps {
echo "Building Docker image: ${env.DOCKER_TAG}"
sh "docker build -f Dockerfile.test -t ${env.DOCKER_TAG} ."
}
}
stage('Prepare Configuration') {
steps {
echo 'Generating environment configuration...'
sh '''
[ -d .venv ] || mkdir .venv
touch .venv/config
chmod 600 .venv/config
cat <<EOF > .venv/config
UYUNI_SERVER=mlm-test-ai-server.mgr.suse.de
UYUNI_MCP_WRITE_TOOLS_ENABLED=true
UYUNI_MCP_TRANSPORT=stdio
UYUNI_MCP_LOG_FILE_PATH=/tmp/mcp-server-uyuni.log
UYUNI_MCP_LOG_LEVEL=DEBUG
EOF
'''
}
}
stage('Run Acceptance Tests') {
steps {
echo 'Running Dockerized tests...'
sh '''
if [ ! -f "$HOME/.ai_secrets" ]; then
echo "ERROR: Required env file $HOME/.secrets not found."
echo "Please provision this file on the agent or generate it via Jenkins credentials in the workspace."
exit 1
fi
docker run --rm \
--env-file .venv/config \
--env-file $HOME/.ai_secrets \
-v $(pwd)/results:/app/results \
-v $(pwd)/test/test_config.json:/app/test_config.json \
--network=host \
$DOCKER_TAG -s test/test_deepeval.py --junit-xml=results/results.xml
'''
}
}
stage('Cleanup') {
steps {
echo 'Cleaning up Docker images and local config...'
sh "docker rmi ${env.DOCKER_TAG} || true"
sh "rm -f .venv/config"
}
}
}
post {
always {
// Archive JUnit Results
junit testResults: 'results/results.xml', allowEmptyResults: true
// Publish HTML Report
publishHTML([
allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'results',
reportFiles: 'report.html',
reportName: 'DeepEval HTML Results',
reportTitles: 'DeepEval Test Report'
])
}
unstable {
emailext (
to: 'discuss-mlm-ai-test-r-aaaatphnhqm7cvlkd7xpw7vlh4@suse.slack.com',
subject: "Unstable Build: ${env.JOB_NAME} #${env.BUILD_NUMBER}",
body: "Tests finished with some failures. Check results at ${env.BUILD_URL}",
attachLog: true
)
}
failure {
emailext (
to: 'discuss-mlm-ai-test-r-aaaatphnhqm7cvlkd7xpw7vlh4@suse.slack.com',
subject: "Build Failed: ${env.JOB_NAME} #${env.BUILD_NUMBER}",
body: "The build failed before completion. See logs: ${env.BUILD_URL}",
recipientProviders: [[$class: 'CulpritsRecipientProvider'], [$class: 'DevelopersRecipientProvider']]
)
}
}
}