-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathJenkinsfile
More file actions
112 lines (98 loc) · 3.49 KB
/
Copy pathJenkinsfile
File metadata and controls
112 lines (98 loc) · 3.49 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
pipeline {
agent {
label 'general-purpose-agent'
}
stages {
stage('Setup & Build') {
steps {
echo '--- Building Project ---'
sh 'chmod +x ./setup.sh'
sh './setup.sh'
}
}
stage('Test & Coverage') {
steps {
echo '--- Running Tests ---'
sh 'chmod +x ./run-coverage-cicd.sh'
sh './run-coverage-cicd.sh'
}
}
stage('Code Analysis') {
steps {
script {
def sonarProjectKey = sh(returnStdout: true, script: 'grep "^sonar.projectKey=" sonar-project.properties | cut -d= -f2').trim()
def sonarHostUrl = "http://sonarqube.cicd.local:9000"
withSonarQubeEnv('SonarQube') {
sh 'sonar-scanner'
}
// 3. Wait for Quality Gate
timeout(time: 5, unit: 'MINUTES') {
def qg = waitForQualityGate()
if (qg.status != 'OK') {
mattermostSend (
color: 'danger',
message: ":no_entry: **Quality Gate Failed**: ${qg.status}\n<${sonarHostUrl}/dashboard?id=${sonarProjectKey}|View Analysis>"
)
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}
}
}
stage('Package') {
steps {
echo '--- Packaging Artifacts ---'
sh 'mkdir -p dist'
dir('build_release') {
sh 'cpack -G TGZ -C Release'
sh 'mv *.tar.gz ../dist/'
}
dir('src/rust') {
sh 'cargo package'
sh 'cp target/package/*.crate ../../dist/'
}
sh 'cp build_release/wheelhouse/*.whl dist/'
}
}
stage('Publish') {
steps {
echo '--- Publishing to Artifactory ---'
rtUpload (
serverId: 'artifactory',
spec: """{
"files": [
{
"pattern": "dist/*",
"target": "generic-local/http-client/${BUILD_NUMBER}/",
"flat": "true"
}
]
}""",
failNoOp: true,
buildName: "${JOB_NAME}",
buildNumber: "${BUILD_NUMBER}"
)
rtPublishBuildInfo (
serverId: 'artifactory',
buildName: "${JOB_NAME}",
buildNumber: "${BUILD_NUMBER}"
)
}
}
}
// Global Post Actions
post {
failure {
mattermostSend (
color: 'danger',
message: ":x: **Build Failed**\n**Job:** ${env.JOB_NAME} #${env.BUILD_NUMBER}\n(<${env.BUILD_URL}|Open Build>)"
)
}
success {
mattermostSend (
color: 'good',
message: ":white_check_mark: **Build Succeeded**\n**Job:** ${env.JOB_NAME} #${env.BUILD_NUMBER}\n(<${env.BUILD_URL}|Open Build>)"
)
}
}
}