ci: support Windows SSH credential binding
这个提交包含在:
父节点
3d696d10d2
当前提交
26dbe8f1de
21
Jenkinsfile
vendored
21
Jenkinsfile
vendored
@ -220,13 +220,20 @@ print('versions.json updated, platformVersion=' + d.get('platformVersion', ''))
|
||||
git diff --cached --quiet || git commit -m "ci: bump versions [${summary}] [skip ci]"
|
||||
"""
|
||||
// push 加 retry + rebase,应对多 job 并发推送冲突
|
||||
sshagent(credentials: ['jenkins-ssh-key']) {
|
||||
retry(3) {
|
||||
bat """
|
||||
chcp 65001 >nul
|
||||
git pull --rebase origin main
|
||||
git push origin HEAD:main
|
||||
"""
|
||||
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"]) {
|
||||
retry(3) {
|
||||
bat """
|
||||
chcp 65001 >nul
|
||||
git pull --rebase origin main
|
||||
git push origin HEAD:main
|
||||
"""
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
bat 'if exist git-ssh.cmd del /f /q git-ssh.cmd'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
正在加载...
在新工单中引用
屏蔽一个用户