diff --git a/jenkins/Jenkinsfile.ai-game-creator-shell-macos-build b/jenkins/Jenkinsfile.ai-game-creator-shell-macos-build index 6e57007b8..71146a824 100644 --- a/jenkins/Jenkinsfile.ai-game-creator-shell-macos-build +++ b/jenkins/Jenkinsfile.ai-game-creator-shell-macos-build @@ -43,6 +43,9 @@ pipeline { // 目的是防止把开发 checkout 当成 Jenkins workspace。 sh ''' set -eu + # 手工「立即构建」时可选参数可能根本没定义(不是空值),先统一成空串/默认值, + # 否则 set -u 会让 Checkout 直接失败。 + SOURCE_BRANCH="${SOURCE_BRANCH:-master}" if [ -n "${AGC_AGENT_ROOT:-}" ]; then case "$WORKSPACE" in "$AGC_AGENT_ROOT"/workspace/*) ;; *) echo "拒绝非专用 Agent 工作区:$WORKSPACE"; exit 1;; esac else @@ -54,6 +57,10 @@ pipeline { withCredentials([sshUserPrivateKey(credentialsId: env.GIT_REMOTE_CREDENTIAL_ID, keyFileVariable: 'GIT_SSH_KEY', usernameVariable: 'GIT_SSH_USER')]) { sh ''' set -eu + # 同上:可选参数在「立即构建」里可能是未定义变量,统一兜底再使用。 + SOURCE_BRANCH="${SOURCE_BRANCH:-master}" + COMMIT_HASH="${COMMIT_HASH:-}" + SKIP_IF_SUPERSEDED="${SKIP_IF_SUPERSEDED:-false}" export GIT_SSH_COMMAND="ssh -i \\"$GIT_SSH_KEY\\" -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes" if [ ! -d .git ]; then git init