ci: split production build Jenkins nodes
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent {
|
agent {
|
||||||
label 'linux && genarrative-build'
|
label 'linux && genarrative-rust-api'
|
||||||
}
|
}
|
||||||
|
|
||||||
options {
|
options {
|
||||||
@@ -10,12 +10,12 @@ pipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
environment {
|
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'
|
||||||
CARGO_HOME = '/var/cache/genarrative-build/api-server/cargo-home'
|
CARGO_HOME = '/home/dsk/.cache/genarrative-jenkins/api-server/cargo-home'
|
||||||
CARGO_TARGET_DIR = '/var/cache/genarrative-build/api-server/cargo-target/prod-release'
|
CARGO_TARGET_DIR = '/home/dsk/.cache/genarrative-jenkins/api-server/cargo-target/prod-release'
|
||||||
CARGO_INCREMENTAL = '0'
|
CARGO_INCREMENTAL = '0'
|
||||||
RUSTC_WRAPPER = 'sccache'
|
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'
|
SCCACHE_CACHE_SIZE = '30G'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ pipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
environment {
|
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 {
|
parameters {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent {
|
agent {
|
||||||
label 'linux && genarrative-build'
|
label 'built-in && windows'
|
||||||
}
|
}
|
||||||
|
|
||||||
options {
|
options {
|
||||||
@@ -10,12 +10,12 @@ pipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
environment {
|
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'
|
||||||
CARGO_HOME = '/var/cache/genarrative-build/stdb-module/cargo-home'
|
CARGO_HOME = '${env.WORKSPACE_TMP}/cargo-home'
|
||||||
CARGO_TARGET_DIR = '/var/cache/genarrative-build/stdb-module/cargo-target/prod-release'
|
CARGO_TARGET_DIR = '${env.WORKSPACE_TMP}/cargo-target/prod-release'
|
||||||
CARGO_INCREMENTAL = '0'
|
CARGO_INCREMENTAL = '0'
|
||||||
RUSTC_WRAPPER = 'sccache'
|
RUSTC_WRAPPER = 'sccache'
|
||||||
SCCACHE_DIR = '/var/cache/genarrative-build/stdb-module/sccache'
|
SCCACHE_DIR = '${env.USERPROFILE}\\.cache\\sccache-stdb-module'
|
||||||
SCCACHE_CACHE_SIZE = '30G'
|
SCCACHE_CACHE_SIZE = '30G'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,16 +41,19 @@ pipeline {
|
|||||||
extensions: [[$class: 'CleanBeforeCheckout']],
|
extensions: [[$class: 'CleanBeforeCheckout']],
|
||||||
userRemoteConfigs: [[url: "${GIT_REMOTE_URL}"]],
|
userRemoteConfigs: [[url: "${GIT_REMOTE_URL}"]],
|
||||||
])
|
])
|
||||||
sh '''
|
powershell '''
|
||||||
bash -lc '
|
$ErrorActionPreference = 'Stop'
|
||||||
set -euo pipefail
|
$sourceBranch = if ($env:SOURCE_BRANCH) { $env:SOURCE_BRANCH } else { 'master' }
|
||||||
chmod +x scripts/jenkins-checkout-source.sh
|
$commitHash = if ($env:COMMIT_HASH) { $env:COMMIT_HASH } else { '' }
|
||||||
SOURCE_BRANCH="${SOURCE_BRANCH:-master}" \
|
$gitRemoteUrl = if ($env:GIT_REMOTE_URL) { $env:GIT_REMOTE_URL } else { 'http://82.157.175.59:3000/GenarrativeAI/Genarrative.git' }
|
||||||
COMMIT_HASH="${COMMIT_HASH:-}" \
|
git fetch --no-tags --prune $gitRemoteUrl "+refs/heads/$sourceBranch:refs/remotes/origin/$sourceBranch"
|
||||||
GIT_REMOTE_URL="${GIT_REMOTE_URL}" \
|
if ($commitHash) {
|
||||||
SOURCE_COMMIT_FILE=".jenkins-source-commit" \
|
git checkout --force $commitHash
|
||||||
scripts/jenkins-checkout-source.sh
|
} else {
|
||||||
'
|
git checkout --force "origin/$sourceBranch"
|
||||||
|
}
|
||||||
|
git clean -ffdx
|
||||||
|
git rev-parse HEAD | Set-Content -Encoding UTF8 .jenkins-source-commit
|
||||||
'''
|
'''
|
||||||
script {
|
script {
|
||||||
env.SOURCE_COMMIT = readFile('.jenkins-source-commit').trim()
|
env.SOURCE_COMMIT = readFile('.jenkins-source-commit').trim()
|
||||||
@@ -61,13 +64,17 @@ pipeline {
|
|||||||
|
|
||||||
stage('Build Stdb Module') {
|
stage('Build Stdb Module') {
|
||||||
steps {
|
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 '
|
bash -lc '
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
chmod +x scripts/jenkins-prepare-cargo-env.sh
|
chmod +x scripts/jenkins-prepare-cargo-env.sh
|
||||||
source 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
|
if ! command -v cargo >/dev/null 2>&1; then
|
||||||
echo "[stdb-build] 缺少 clang/lld。请先运行 Genarrative-Server-Provision 安装 Linux 构建依赖。" >&2
|
echo "[stdb-build] 缺少 cargo。请先在 Windows 构建节点安装 Rust 工具链。" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if ! command -v sccache >/dev/null 2>&1; then
|
if ! command -v sccache >/dev/null 2>&1; then
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ pipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
environment {
|
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'
|
WEB_ARTIFACT_ROOT = '/var/cache/genarrative-build/web-artifacts'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user