ci: support Windows SSH credential binding

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

22
Jenkinsfile vendored
查看文件

@ -93,9 +93,18 @@ pipeline {
stage('SNAPSHOT: Push main') {
when { expression { params.SNAPSHOT } }
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 "git push origin HEAD:main"
}
} finally {
bat 'if exist git-ssh.cmd del /f /q git-ssh.cmd'
}
}
}
echo "SNAPSHOT 已推送到 main 分支"
echo "应用端 project.yml 保持 branch: main 即可自动获取最新代码"
}
@ -109,10 +118,19 @@ pipeline {
bat "git add version.properties"
bat """git commit -m "ci: release %RELEASE_TAG% [%CHANGED_MODULES%]" """
bat "git tag %RELEASE_TAG%"
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 "git push origin HEAD:main"
bat "git push origin %RELEASE_TAG%"
}
} finally {
bat 'if exist git-ssh.cmd del /f /q git-ssh.cmd'
}
}
}
}
}

查看文件

@ -397,3 +397,8 @@ pod repo add xuqm-specs https://xuqinmin.com/xuqinmin12/xuqm-specs.git
pod spec lint XuqmSDK.podspec --allow-warnings
pod repo push xuqm-specs XuqmSDK.podspec --allow-warnings
```
### Jenkins SSH
Windows Jenkins 节点通过 `jenkins-ssh-key` 私钥凭据生成构建期临时
`git-ssh.cmd` 执行主分支和标签推送,作用域结束后立即删除该脚本。