forked from Miladeb77/Y2_Genepanel_project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
85 lines (85 loc) · 2.9 KB
/
Jenkinsfile
File metadata and controls
85 lines (85 loc) · 2.9 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
pipeline {
agent any
environment {
IMAGE_NAME = "genepanel-app" // Name of the Docker image
CONTAINER_NAME = "genepanel-container" // Name of the Docker container
TEST_RESULTS_DIR = "output/test-results" // Directory for test results
TEST_DIR = "tests" // Directory containing tests
}
stages {
stage("Checkout Code") {
steps {
echo "Checking out the source code from GitHub..."
git branch: 'development', url: 'https://github.com/Miladeb77/Y2_Genepanel_project.git'
}
}
stage("Build Docker Image") {
steps {
script {
echo "Building the Docker image..."
bat """
docker build -t %IMAGE_NAME% .
"""
}
}
}
stage("Run Unit Tests in Docker Container") {
steps {
script {
echo "Running tests in the Docker container..."
bat """
docker run --rm --name %CONTAINER_NAME% ^
-v %WORKSPACE%\\%TEST_RESULTS_DIR%:/app/output ^
%IMAGE_NAME% pytest /app/%TEST_DIR% --junitxml=/app/output/test-results.xml
"""
}
}
}
stage("Archive Test Results") {
steps {
echo "Archiving test results..."
junit "**/${TEST_RESULTS_DIR}/test-results.xml"
}
}
stage("Lint and Static Code Analysis") {
steps {
script {
echo "Running flake8 for linting..."
bat """
docker run --rm --name %CONTAINER_NAME% ^
%IMAGE_NAME% flake8 PanelGeneMapper/ > lint-results.txt || true
"""
}
archiveArtifacts artifacts: "lint-results.txt", allowEmptyArchive: true
}
}
stage("Generate Documentation") {
steps {
script {
echo "Generating documentation with pdoc..."
bat """
docker run --rm --name %CONTAINER_NAME% ^
%IMAGE_NAME% pdoc --html --output-dir /app/docs PanelGeneMapper/
"""
}
archiveArtifacts artifacts: "/app/docs/**", allowEmptyArchive: true
}
}
}
post {
always {
script {
echo "Cleaning up Docker resources..."
bat """
docker system prune --all --volumes --force || true
"""
}
}
success {
echo "Pipeline executed successfully!"
}
failure {
echo "Pipeline failed. Check logs for details."
}
}
}