ci: support Windows SSH credential binding
这个提交包含在:
父节点
d13b9f2c62
当前提交
0201ff8b27
28
Jenkinsfile
vendored
28
Jenkinsfile
vendored
@ -93,8 +93,17 @@ pipeline {
|
|||||||
stage('SNAPSHOT: Push main') {
|
stage('SNAPSHOT: Push main') {
|
||||||
when { expression { params.SNAPSHOT } }
|
when { expression { params.SNAPSHOT } }
|
||||||
steps {
|
steps {
|
||||||
sshagent(credentials: ['jenkins-ssh-key']) {
|
script {
|
||||||
bat "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"]) {
|
||||||
|
bat "git push origin HEAD:main"
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
bat 'if exist git-ssh.cmd del /f /q git-ssh.cmd'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
echo "SNAPSHOT 已推送到 main 分支"
|
echo "SNAPSHOT 已推送到 main 分支"
|
||||||
echo "应用端 project.yml 保持 branch: main 即可自动获取最新代码"
|
echo "应用端 project.yml 保持 branch: main 即可自动获取最新代码"
|
||||||
@ -109,9 +118,18 @@ pipeline {
|
|||||||
bat "git add version.properties"
|
bat "git add version.properties"
|
||||||
bat """git commit -m "ci: release %RELEASE_TAG% [%CHANGED_MODULES%]" """
|
bat """git commit -m "ci: release %RELEASE_TAG% [%CHANGED_MODULES%]" """
|
||||||
bat "git tag %RELEASE_TAG%"
|
bat "git tag %RELEASE_TAG%"
|
||||||
sshagent(credentials: ['jenkins-ssh-key']) {
|
script {
|
||||||
bat "git push origin HEAD:main"
|
withCredentials([sshUserPrivateKey(credentialsId: 'jenkins-ssh-key', keyFileVariable: 'GIT_SSH_KEY')]) {
|
||||||
bat "git push origin %RELEASE_TAG%"
|
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 spec lint XuqmSDK.podspec --allow-warnings
|
||||||
pod repo push xuqm-specs XuqmSDK.podspec --allow-warnings
|
pod repo push xuqm-specs XuqmSDK.podspec --allow-warnings
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Jenkins SSH
|
||||||
|
|
||||||
|
Windows Jenkins 节点通过 `jenkins-ssh-key` 私钥凭据生成构建期临时
|
||||||
|
`git-ssh.cmd` 执行主分支和标签推送,作用域结束后立即删除该脚本。
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户