Files
tictactoe/Jenkinsfile
duynguyen 474545b24e feat: add session score display and refactor Jenkinsfile
Score tracks X wins, O wins, draws in-memory for current session.
Jenkinsfile rewritten as scripted pipeline with named execute functions
and per-branch strategy closures (mirrors BasePipeline pattern).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 14:53:42 +07:00

71 lines
2.1 KiB
Groovy

@Library('homelab') _
import vn.fireflylab.pipeline.BranchStrategy
// ── Stage functions ────────────────────────────────────────────────
def executeInstallTest() {
stage('Install & Test') {
container('node') { runNodeTest() }
}
}
def executeBuildPush() {
stage('Build & Push') {
container('docker') {
def tag = BranchStrategy.imageTag(env.BRANCH_NAME)
env.IMAGE_TAG = tag
dockerBuildPush(appName: 'tictactoe', 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 tictactoe chart to ${env.IMAGE_TAG}"
)
}
}
}
// ── Pipeline ───────────────────────────────────────────────────────
podTemplate(yaml: homelabK8sAgent(withTools: true)) {
node(POD_LABEL) {
withEnv(['DOCKER_HOST=tcp://localhost:2375']) {
checkout scm
BranchStrategy.prStrategy(env.BRANCH_NAME) {
executeInstallTest()
}
BranchStrategy.featureStrategy(env.BRANCH_NAME) {
executeInstallTest()
executeBuildPush()
}
BranchStrategy.developStrategy(env.BRANCH_NAME) {
executeInstallTest()
executeBuildPush()
}
BranchStrategy.mainStrategy(env.BRANCH_NAME) {
executeInstallTest()
executeBuildPush()
}
BranchStrategy.releaseStrategy(env.BRANCH_NAME) {
executeInstallTest()
executeBuildPush()
}
BranchStrategy.hotfixStrategy(env.BRANCH_NAME) {
executeInstallTest()
executeBuildPush()
}
}
}
}