From 5351b5f87c3b72582d4d16904636dfb78a080a79 Mon Sep 17 00:00:00 2001 From: kdletters Date: Tue, 1 Sep 2026 11:48:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DAGC=E6=B5=81=E6=B0=B4?= =?UTF-8?q?=E7=BA=BFSSH=E5=87=AD=E6=8D=AE=E6=B3=A8=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 改用Jenkins凭据绑定支持Windows源码检出 使用显式Git和临时SSH密钥连接Gitea --- jenkins/Jenkinsfile.ai-game-creator-shell-build | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jenkins/Jenkinsfile.ai-game-creator-shell-build b/jenkins/Jenkinsfile.ai-game-creator-shell-build index bfbe19901..e8cdb7096 100644 --- a/jenkins/Jenkinsfile.ai-game-creator-shell-build +++ b/jenkins/Jenkinsfile.ai-game-creator-shell-build @@ -28,8 +28,9 @@ pipeline { stages { stage('Checkout') { steps { - sshagent(credentials: [env.GIT_REMOTE_CREDENTIAL_ID]) { - powershell ''' + withCredentials([sshUserPrivateKey(credentialsId: env.GIT_REMOTE_CREDENTIAL_ID, keyFileVariable: 'GIT_SSH_KEY', usernameVariable: 'GIT_SSH_USER')]) { + withEnv(["GIT_SSH_COMMAND=ssh -i \"${env.GIT_SSH_KEY}\" -o StrictHostKeyChecking=no"]) { + powershell ''' $ErrorActionPreference = 'Stop' $git = 'C:\\Tools\\Git\\cmd\\git.exe' if (-not (Test-Path $git)) { throw "找不到 Git: $git" } @@ -64,7 +65,8 @@ pipeline { $resolved = (& $git rev-parse HEAD).Trim() Set-Content -Path '.jenkins-source-commit' -Value $resolved -NoNewline Write-Host "源码 commit=$resolved" - ''' + ''' + } } } }