sonar sidecar container, unique image tags, real k8s deploy stage
This commit is contained in:
51
platform/Jenkinsfile
vendored
51
platform/Jenkinsfile
vendored
@@ -17,40 +17,61 @@ pipeline {
|
|||||||
stage('Build Docker Image') {
|
stage('Build Docker Image') {
|
||||||
steps {
|
steps {
|
||||||
sh '''
|
sh '''
|
||||||
docker build -t management-platform:latest ./platform/
|
docker build -t management-platform:${BUILD_NUMBER} -t management-platform:latest ./platform/
|
||||||
echo "✅ Docker image built"
|
echo "✅ Docker image built"
|
||||||
docker images management-platform:latest --format "Size: {{.Size}}"
|
docker images management-platform:${BUILD_NUMBER} --format "Size: {{.Size}}"
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('SonarQube Analysis') {
|
stage('SonarQube Analysis') {
|
||||||
steps {
|
steps {
|
||||||
withSonarQubeEnv('sonarqube') {
|
container('sonar-scanner') {
|
||||||
script {
|
withSonarQubeEnv('sonarqube') {
|
||||||
def scannerHome = tool 'sonar-scanner'
|
script {
|
||||||
sh """
|
def scannerHome = tool 'sonar-scanner'
|
||||||
${scannerHome}/bin/sonar-scanner \
|
sh """
|
||||||
-Dsonar.projectKey=management-platform \
|
${scannerHome}/bin/sonar-scanner \
|
||||||
-Dsonar.sources=platform \
|
-Dsonar.projectKey=management-platform \
|
||||||
-Dsonar.python.version=3
|
-Dsonar.sources=platform \
|
||||||
"""
|
-Dsonar.python.version=3
|
||||||
|
"""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Deploy to Kubernetes [TODO - not implemented yet]') {
|
stage('Deploy to Kubernetes') {
|
||||||
steps {
|
steps {
|
||||||
echo '⚠️ K8s deploy stage not implemented yet — image built but not pushed to the cluster.'
|
container('docker-cli') {
|
||||||
echo 'Image import + kubectl rollout still needs to be designed (RBAC + pod template + image transfer).'
|
sh '''
|
||||||
|
docker save management-platform:${BUILD_NUMBER} | \
|
||||||
|
/usr/local/bin/k3s ctr -a /run/k3s/containerd/containerd.sock -n k8s.io images import -
|
||||||
|
|
||||||
|
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
|
||||||
|
CACERT=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
|
||||||
|
|
||||||
|
/usr/local/bin/kubectl --server=https://kubernetes.default.svc \
|
||||||
|
--token="$TOKEN" --certificate-authority="$CACERT" \
|
||||||
|
set image deployment/management-platform \
|
||||||
|
management-platform=management-platform:${BUILD_NUMBER} \
|
||||||
|
-n management-platform
|
||||||
|
|
||||||
|
/usr/local/bin/kubectl --server=https://kubernetes.default.svc \
|
||||||
|
--token="$TOKEN" --certificate-authority="$CACERT" \
|
||||||
|
rollout status deployment/management-platform -n management-platform --timeout=90s
|
||||||
|
|
||||||
|
echo "✅ Deployed management-platform:${BUILD_NUMBER} to Kubernetes"
|
||||||
|
'''
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
post {
|
post {
|
||||||
success {
|
success {
|
||||||
echo '✅ Pipeline succeeded — build + Sonar passed, k8s deploy pending'
|
echo '✅ Pipeline succeeded — build + Sonar passed, deployed to k8s'
|
||||||
}
|
}
|
||||||
failure {
|
failure {
|
||||||
echo '❌ Pipeline failed — check logs'
|
echo '❌ Pipeline failed — check logs'
|
||||||
|
|||||||
Reference in New Issue
Block a user