修复AGC流水线SSH凭据注入
Project CI / Repository checks (pull_request) Failing after 9s
Project CI / Backend tests (pull_request) Failing after 10s
Project CI / Frontend tests (pull_request) Successful in 3m22s
Project CI / Native shell tests (pull_request) Failing after 17m40s

改用Jenkins凭据绑定支持Windows源码检出

使用显式Git和临时SSH密钥连接Gitea
This commit is contained in:
2026-09-01 11:48:32 +08:00
parent 322cc84115
commit 5351b5f87c
@@ -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"
'''
'''
}
}
}
}