From e991c06bffce66fd29f626bfa71e0b1f56d98331 Mon Sep 17 00:00:00 2001 From: XuqmGroup Date: Mon, 27 Jul 2026 12:58:29 +0800 Subject: [PATCH] ci: support Windows SSH credential binding --- Jenkinsfile | 25 ++++++++++++++++--------- README.md | 5 +++++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8578258..ffd67de 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -188,15 +188,22 @@ pipeline { stage('Commit Version Bump') { when { expression { !params.SNAPSHOT } } steps { - sshagent(credentials: ['jenkins-ssh-key']) { - script { - bat """ - git config user.email "jenkins@xuqm.com" - git config user.name "Jenkins CI" - git add gradle.properties - git diff --cached --quiet || git commit -m "ci: bump module versions [${env.PUBLISH_MODULES}]" - git push origin HEAD:main - """ + 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 config user.email "jenkins@xuqm.com" + git config user.name "Jenkins CI" + git add gradle.properties + git diff --cached --quiet || git commit -m "ci: bump module versions [${env.PUBLISH_MODULES}]" + git push origin HEAD:main + """ + } + } finally { + bat 'if exist git-ssh.cmd del /f /q git-ssh.cmd' + } } } } diff --git a/README.md b/README.md index df2b8a5..c6e4dc1 100644 --- a/README.md +++ b/README.md @@ -483,3 +483,8 @@ controller?.postMessageToWeb("window.dispatchEvent(new CustomEvent('nativeMsg', ``` 发布至 `https://nexus.xuqinmin.com/repository/android-hosted/`,groupId `com.xuqm`,版本号在各模块 `build.gradle.kts` 中维护。 + +### Jenkins SSH + +Windows Jenkins 节点通过 `jenkins-ssh-key` 私钥凭据生成构建期临时 +`git-ssh.cmd` 执行版本提交推送,作用域结束后立即删除该脚本。