Files
tcb_devportal/Jenkinsfile
duynguyen df0e5888d9
Some checks failed
homelab-k8s-services/tcb_devportal/pipeline/head There was a failure building this commit
ci: merge install into Unit Test stage, drop separate Install stage
2026-05-10 16:28:22 +07:00

94 lines
2.8 KiB
Groovy

@Library('homelab') _
import vn.fireflylab.pipeline.BranchStrategy
// ── Stage functions ────────────────────────────────────────────────
def executeUnitTest() {
stage('Unit Test') {
container('node') {
runNodeInstall()
runNodeTest(testCmd: 'run test:coverage')
}
}
}
def executeScanCodeQuality() {
stage('Scan Code Quality') {
container('sonar') {
scanCodeQuality(projectKey: 'tcb_devportal')
}
}
}
def executeBuildPush() {
stage('Build & Push') {
container('docker') {
def tag = BranchStrategy.imageTag(env.BRANCH_NAME)
env.IMAGE_TAG = tag
dockerBuildPush(appName: 'tcb_devportal', tag: tag)
}
}
}
def executeBumpChart() {
stage('Bump Helm Chart') {
container('tools') {
bumpHelmChart(imageTag: env.IMAGE_TAG)
gitCommitPush(
files: ['manifest/helm/Chart.yaml', 'manifest/helm/values.yaml'],
message: "ci: bump tcb_devportal chart to ${env.IMAGE_TAG}"
)
}
}
}
// ── Pipeline ───────────────────────────────────────────────────────
// PR-* → test
// feature/* → test + scan + build + push
// develop → test + scan + build + push
// main → test + scan + build + push
// release/x.y.z → test + scan + build + push
// hotfix/* → test + scan + build + push
podTemplate(yaml: homelabK8sAgent(withTools: true, withSonar: true)) {
node(POD_LABEL) {
withEnv(['DOCKER_HOST=tcp://localhost:2375']) {
checkout scm
BranchStrategy.prStrategy(env.BRANCH_NAME) {
executeUnitTest()
}
BranchStrategy.featureStrategy(env.BRANCH_NAME) {
executeUnitTest()
executeScanCodeQuality()
executeBuildPush()
}
BranchStrategy.developStrategy(env.BRANCH_NAME) {
executeUnitTest()
executeScanCodeQuality()
executeBuildPush()
}
BranchStrategy.mainStrategy(env.BRANCH_NAME) {
executeUnitTest()
executeScanCodeQuality()
executeBuildPush()
}
BranchStrategy.releaseStrategy(env.BRANCH_NAME) {
executeUnitTest()
executeScanCodeQuality()
executeBuildPush()
}
BranchStrategy.hotfixStrategy(env.BRANCH_NAME) {
executeUnitTest()
executeScanCodeQuality()
executeBuildPush()
}
}
}
}