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>
This commit is contained in:
2026-04-27 14:53:42 +07:00
parent 9c5243290d
commit 474545b24e
4 changed files with 97 additions and 36 deletions

89
Jenkinsfile vendored
View File

@@ -2,51 +2,68 @@
import vn.fireflylab.pipeline.BranchStrategy
pipeline {
agent {
kubernetes {
yaml homelabK8sAgent(withTools: true)
// ── 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)
}
}
}
environment {
DOCKER_HOST = 'tcp://localhost:2375'
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}"
)
}
}
}
stages {
stage('Install & Test') {
steps {
container('node') {
runNodeTest()
}
// ── Pipeline ───────────────────────────────────────────────────────
podTemplate(yaml: homelabK8sAgent(withTools: true)) {
node(POD_LABEL) {
withEnv(['DOCKER_HOST=tcp://localhost:2375']) {
checkout scm
BranchStrategy.prStrategy(env.BRANCH_NAME) {
executeInstallTest()
}
}
stage('Build & Push Image') {
when { expression { BranchStrategy.shouldBuildImage(env.BRANCH_NAME) } }
steps {
container('docker') {
script {
def tag = BranchStrategy.imageTag(env.BRANCH_NAME)
env.IMAGE_TAG = tag
dockerBuildPush(appName: 'tictactoe', tag: tag)
}
}
BranchStrategy.featureStrategy(env.BRANCH_NAME) {
executeInstallTest()
executeBuildPush()
}
}
stage('Bump Helm Chart') {
when { expression { BranchStrategy.shouldBumpChart(env.BRANCH_NAME) } }
steps {
container('tools') {
script {
bumpHelmChart(imageTag: env.IMAGE_TAG)
gitCommitPush(
files: ['manifest/helm/Chart.yaml', 'manifest/helm/values.yaml'],
message: "ci: bump tictactoe chart to ${env.IMAGE_TAG}"
)
}
}
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()
}
}
}