This commit is contained in:
hiondal
2025-03-03 16:58:14 +09:00
parent 6ceaca8208
commit 3301d09288
2 changed files with 32 additions and 139 deletions
+32 -2
View File
@@ -13,10 +13,12 @@ podTemplate(
containerTemplate(name: 'node', image: 'node:20-slim', ttyEnabled: true, command: 'cat'),
containerTemplate(name: 'podman', image: "mgoltzsche/podman", ttyEnabled: true, command: 'cat', privileged: true),
containerTemplate(name: 'azure-cli', image: 'hiondal/azure-kubectl:latest', command: 'cat', ttyEnabled: true),
containerTemplate(name: 'envsubst', image: "hiondal/envsubst", command: 'sleep', args: '1h')
containerTemplate(name: 'envsubst', image: "hiondal/envsubst", command: 'sleep', args: '1h'),
containerTemplate(name: 'sonar-scanner', image: 'sonarsource/sonar-scanner-cli:latest', command: 'cat', ttyEnabled: true)
],
volumes: [
emptyDirVolume(mountPath: '/root/.azure', memory: false)
emptyDirVolume(mountPath: '/root/.azure', memory: false),
emptyDirVolume(mountPath: '/opt/sonar-scanner/.sonar/cache', memory: false)
]
) {
node(PIPELINE_ID) {
@@ -24,6 +26,7 @@ podTemplate(
def imageTag = getImageTag()
def manifest = "deploy.yaml"
def namespace
def sonarScannerHome = '/opt/sonar-scanner'
stage("Get Source") {
checkout scm
@@ -31,6 +34,33 @@ podTemplate(
namespace = "${props.namespace}"
}
stage('Code Analysis & Quality Gate') {
container('node') {
sh "npm install"
sh "npm test -- --coverage --passWithNoTests" //test code 없어도 통과되게 함
}
container('sonar-scanner') {
withSonarQubeEnv('SonarQube') {
sh """
${sonarScannerHome}/bin/sonar-scanner \
-Dsonar.projectKey=lifesub-web \
-Dsonar.sources=src \
-Dsonar.tests=src \
-Dsonar.test.inclusions=src/**/*.test.js,src/**/*.test.jsx \
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
"""
}
}
timeout(time: 10, unit: 'MINUTES') {
def qg = waitForQualityGate()
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}
stage("Setup AKS") {
container('azure-cli') {
withCredentials([azureServicePrincipal('azure-credentials')]) {