-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
64 lines (54 loc) · 2.45 KB
/
Jenkinsfile
File metadata and controls
64 lines (54 loc) · 2.45 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
pipeline {
agent any
environment {
// Define the Docker container image you're using
DOCKER_IMAGE = 'playwright-sample-project' // Replace with your Docker image name
CONTAINER_NAME = 'friendly_wilson' // Name of your pre-existing container
ALLURE_RESULTS_DIR = 'allure-results' // Directory where Allure stores the results
ALLURE_REPORT_DIR = '/app/reports/allure-report' // Directory to store the generated Allure report
}
stages {
stage('Checkout') {
steps {
// Checkout the code from your repository
checkout scm
}
}
stage('Run Playwright Tests') {
steps {
ansiColor('xterm') { // Apply ANSI color support
script {
// Start your pre-existing Docker container if not already running
def containerRunning = bat(script: "docker ps -q -f name=${CONTAINER_NAME}", returnStdout: true).trim()
if (!containerRunning) {
// If the container is not running, start it
echo "Starting container ${CONTAINER_NAME}"
// You can use docker start if it exists or docker run to create a new container if needed
bat "docker start ${CONTAINER_NAME} || docker run -d --name ${CONTAINER_NAME} ${DOCKER_IMAGE}"
} else {
echo "Container ${CONTAINER_NAME} is already running"
}
// Run the test script inside the container and generate the Allure report
echo "Running Playwright tests inside the container"
bat "docker exec ${CONTAINER_NAME} ./run_test_suite.sh"
}
}
}
}
stage('Publish Allure Report') {
steps {
script {
echo "Copying Allure report from container to Jenkins workspace"
// Copy the Allure report directory from the container to the workspace
bat "docker cp ${CONTAINER_NAME}:${ALLURE_REPORT_DIR} ${WORKSPACE}/allure-report"
}
}
}
}
post {
always {
// Clean workspace or perform any necessary post-build actions
cleanWs()
}
}
}