From 96e1d7c4fb9969f3327891fde069353aacc435da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8E=86=E5=86=B0=E9=83=81-hermes=E7=89=88?= Date: Wed, 6 May 2026 14:04:12 +0800 Subject: [PATCH] ci: split production build Jenkins nodes --- jenkins/Jenkinsfile.production-api-build | 10 ++--- ...nkinsfile.production-full-build-and-deploy | 2 +- .../Jenkinsfile.production-stdb-module-build | 43 +++++++++++-------- jenkins/Jenkinsfile.production-web-build | 2 +- 4 files changed, 32 insertions(+), 25 deletions(-) diff --git a/jenkins/Jenkinsfile.production-api-build b/jenkins/Jenkinsfile.production-api-build index a76f354a..317c610a 100644 --- a/jenkins/Jenkinsfile.production-api-build +++ b/jenkins/Jenkinsfile.production-api-build @@ -1,6 +1,6 @@ pipeline { agent { - label 'linux && genarrative-build' + label 'linux && genarrative-rust-api' } options { @@ -10,12 +10,12 @@ pipeline { } environment { - GIT_REMOTE_URL = 'http://127.0.0.1:3000/GenarrativeAI/Genarrative.git' - CARGO_HOME = '/var/cache/genarrative-build/api-server/cargo-home' - CARGO_TARGET_DIR = '/var/cache/genarrative-build/api-server/cargo-target/prod-release' + GIT_REMOTE_URL = 'http://82.157.175.59:3000/GenarrativeAI/Genarrative.git' + CARGO_HOME = '/home/dsk/.cache/genarrative-jenkins/api-server/cargo-home' + CARGO_TARGET_DIR = '/home/dsk/.cache/genarrative-jenkins/api-server/cargo-target/prod-release' CARGO_INCREMENTAL = '0' RUSTC_WRAPPER = 'sccache' - SCCACHE_DIR = '/var/cache/genarrative-build/api-server/sccache' + SCCACHE_DIR = '/home/dsk/.cache/genarrative-jenkins/api-server/sccache' SCCACHE_CACHE_SIZE = '30G' } diff --git a/jenkins/Jenkinsfile.production-full-build-and-deploy b/jenkins/Jenkinsfile.production-full-build-and-deploy index d3c50f4b..87ecbb2b 100644 --- a/jenkins/Jenkinsfile.production-full-build-and-deploy +++ b/jenkins/Jenkinsfile.production-full-build-and-deploy @@ -12,7 +12,7 @@ pipeline { } environment { - GIT_REMOTE_URL = 'http://127.0.0.1:3000/GenarrativeAI/Genarrative.git' + GIT_REMOTE_URL = 'http://82.157.175.59:3000/GenarrativeAI/Genarrative.git' } parameters { diff --git a/jenkins/Jenkinsfile.production-stdb-module-build b/jenkins/Jenkinsfile.production-stdb-module-build index 17aec0c2..75a07adf 100644 --- a/jenkins/Jenkinsfile.production-stdb-module-build +++ b/jenkins/Jenkinsfile.production-stdb-module-build @@ -1,6 +1,6 @@ pipeline { agent { - label 'linux && genarrative-build' + label 'built-in && windows' } options { @@ -10,12 +10,12 @@ pipeline { } environment { - GIT_REMOTE_URL = 'http://127.0.0.1:3000/GenarrativeAI/Genarrative.git' - CARGO_HOME = '/var/cache/genarrative-build/stdb-module/cargo-home' - CARGO_TARGET_DIR = '/var/cache/genarrative-build/stdb-module/cargo-target/prod-release' + GIT_REMOTE_URL = 'http://82.157.175.59:3000/GenarrativeAI/Genarrative.git' + CARGO_HOME = '${env.WORKSPACE_TMP}/cargo-home' + CARGO_TARGET_DIR = '${env.WORKSPACE_TMP}/cargo-target/prod-release' CARGO_INCREMENTAL = '0' RUSTC_WRAPPER = 'sccache' - SCCACHE_DIR = '/var/cache/genarrative-build/stdb-module/sccache' + SCCACHE_DIR = '${env.USERPROFILE}\\.cache\\sccache-stdb-module' SCCACHE_CACHE_SIZE = '30G' } @@ -41,16 +41,19 @@ pipeline { extensions: [[$class: 'CleanBeforeCheckout']], userRemoteConfigs: [[url: "${GIT_REMOTE_URL}"]], ]) - sh ''' - bash -lc ' - set -euo pipefail - chmod +x scripts/jenkins-checkout-source.sh - SOURCE_BRANCH="${SOURCE_BRANCH:-master}" \ - COMMIT_HASH="${COMMIT_HASH:-}" \ - GIT_REMOTE_URL="${GIT_REMOTE_URL}" \ - SOURCE_COMMIT_FILE=".jenkins-source-commit" \ - scripts/jenkins-checkout-source.sh - ' + powershell ''' + $ErrorActionPreference = 'Stop' + $sourceBranch = if ($env:SOURCE_BRANCH) { $env:SOURCE_BRANCH } else { 'master' } + $commitHash = if ($env:COMMIT_HASH) { $env:COMMIT_HASH } else { '' } + $gitRemoteUrl = if ($env:GIT_REMOTE_URL) { $env:GIT_REMOTE_URL } else { 'http://82.157.175.59:3000/GenarrativeAI/Genarrative.git' } + git fetch --no-tags --prune $gitRemoteUrl "+refs/heads/$sourceBranch:refs/remotes/origin/$sourceBranch" + if ($commitHash) { + git checkout --force $commitHash + } else { + git checkout --force "origin/$sourceBranch" + } + git clean -ffdx + git rev-parse HEAD | Set-Content -Encoding UTF8 .jenkins-source-commit ''' script { env.SOURCE_COMMIT = readFile('.jenkins-source-commit').trim() @@ -61,13 +64,17 @@ pipeline { stage('Build Stdb Module') { steps { - sh ''' + powershell ''' + $ErrorActionPreference = 'Stop' + if (-not (Get-Command bash -ErrorAction SilentlyContinue)) { + throw '[stdb-build] Windows 构建节点缺少 bash,无法执行仓库现有生产构建脚本。请先安装 Git Bash 或 WSL bash,并确保 bash 在 PATH 中。' + } bash -lc ' set -euo pipefail chmod +x scripts/jenkins-prepare-cargo-env.sh source scripts/jenkins-prepare-cargo-env.sh - if ! command -v clang >/dev/null 2>&1 || ! command -v lld >/dev/null 2>&1; then - echo "[stdb-build] 缺少 clang/lld。请先运行 Genarrative-Server-Provision 安装 Linux 构建依赖。" >&2 + if ! command -v cargo >/dev/null 2>&1; then + echo "[stdb-build] 缺少 cargo。请先在 Windows 构建节点安装 Rust 工具链。" >&2 exit 1 fi if ! command -v sccache >/dev/null 2>&1; then diff --git a/jenkins/Jenkinsfile.production-web-build b/jenkins/Jenkinsfile.production-web-build index e42d29c4..460a8cd7 100644 --- a/jenkins/Jenkinsfile.production-web-build +++ b/jenkins/Jenkinsfile.production-web-build @@ -10,7 +10,7 @@ pipeline { } environment { - GIT_REMOTE_URL = 'http://127.0.0.1:3000/GenarrativeAI/Genarrative.git' + GIT_REMOTE_URL = 'http://82.157.175.59:3000/GenarrativeAI/Genarrative.git' WEB_ARTIFACT_ROOT = '/var/cache/genarrative-build/web-artifacts' }