ci: support Windows SSH credential binding

这个提交包含在:
XuqmGroup 2026-07-27 12:58:29 +08:00
父节点 c56eb1abff
当前提交 d44016276f
共有 2 个文件被更改,包括 23 次插入9 次删除

11
Jenkinsfile vendored
查看文件

@ -148,7 +148,11 @@ print('versions.json updated: ${svcName}=${svcVer}')
stage('Commit Version') { stage('Commit Version') {
steps { steps {
sshagent(credentials: ['jenkins-ssh-key']) { script {
withCredentials([sshUserPrivateKey(credentialsId: 'jenkins-ssh-key', keyFileVariable: 'GIT_SSH_KEY')]) {
writeFile file: 'git-ssh.cmd', text: '@echo off\r\nssh -i "%GIT_SSH_KEY%" -o IdentitiesOnly=yes %*\r\n', encoding: 'UTF-8'
try {
withEnv(["GIT_SSH=${pwd()}\\git-ssh.cmd"]) {
bat """ bat """
chcp 65001 >nul chcp 65001 >nul
git config user.email "jenkins@xuqm.com" git config user.email "jenkins@xuqm.com"
@ -158,6 +162,11 @@ print('versions.json updated: ${svcName}=${svcVer}')
git push origin HEAD:main git push origin HEAD:main
""" """
} }
} finally {
bat 'if exist git-ssh.cmd del /f /q git-ssh.cmd'
}
}
}
} }
} }
} }

查看文件

@ -183,3 +183,8 @@ location /api/ {
proxy_pass http://127.0.0.1:8081/api/; proxy_pass http://127.0.0.1:8081/api/;
} }
``` ```
### Jenkins SSH
Windows Jenkins 节点通过 `jenkins-ssh-key` 私钥凭据生成构建期临时
`git-ssh.cmd` 执行版本提交推送,作用域结束后立即删除该脚本。