-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
95 lines (88 loc) · 2.94 KB
/
Copy pathJenkinsfile
File metadata and controls
95 lines (88 loc) · 2.94 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
pipeline {
agent { label 'linux && gpu && compute' }
environment {
SONAR_HOST_URL = 'http://127.0.0.1:9200'
SONAR_PROJECT_KEY = 'curator'
DEPLOY_PLAYBOOK = 'deploy/ansible-deploy.yml'
}
options {
timeout(time: 60, unit: 'MINUTES')
disableConcurrentBuilds()
}
stages {
stage('Trivy Security Scan') {
agent {
docker {
image 'registry.starbluesolutions.net/aquasec/trivy:0.69.3'
reuseNode true
args '--entrypoint="" -u root --network host'
}
}
steps {
sh '''trivy fs \
--server http://127.0.0.1:4954 \
--exit-code 1 \
--severity HIGH,CRITICAL \
--scanners vuln,secret \
--format table \
.'''
}
}
stage('Run Tests') {
agent {
docker {
image 'registry.starbluesolutions.net/astral-sh/uv:python3.11-bookworm-slim'
reuseNode true
args '-u root --network host'
}
}
steps {
sh 'uv sync --extra dev --frozen'
catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') {
sh '.venv/bin/pytest tests/ --tb=short -q --cov=src --cov-report=xml:coverage.xml'
}
}
}
stage('SonarQube Analysis') {
agent {
docker {
image 'registry.starbluesolutions.net/sonarsource/sonar-scanner-cli:latest'
reuseNode true
args '-u root --network host'
}
}
steps {
withCredentials([string(credentialsId: 'sonarqube-token-curator', variable: 'SONAR_TOKEN')]) {
sh '''sonar-scanner \
-Dsonar.projectKey="${SONAR_PROJECT_KEY}" \
-Dsonar.sources=src \
-Dsonar.tests=tests \
-Dsonar.python.coverage.reportPaths=coverage.xml \
-Dsonar.host.url="${SONAR_HOST_URL}" \
-Dsonar.token="${SONAR_TOKEN}"'''
}
}
}
stage('Deploy') {
steps {
sh '''ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook \
-i "127.0.0.1," \
"${DEPLOY_PLAYBOOK}" \
--connection local \
-e "curator_src_dir=${WORKSPACE}" \
-e "build_number=${BUILD_NUMBER}"'''
}
}
}
post {
always {
deleteDir()
}
success {
echo 'Pipeline completed successfully.'
}
failure {
echo 'Pipeline failed.'
}
}
}