我已经创建了以下脚本,以从开发创建发行/测试分支并将其推送到远程。
stage('create branch')
{
stdout = sh(script:'git checkout -b release/test3', returnStdout: true)
println("GIT add stdout ################ " + stdout + " ####################")
withCredentials([usernamePassword(credentialsId: 'gitlogin', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')])
{
sh('git push origin release/test3')
}
}
分支是在本地创建的,但是我无法将其推送到远程。
下面是错误消息:
+ git checkout -b release/test3
Switched to a new branch 'release/test3'
[Pipeline] echo
GIT add stdout ################ ####################
[Pipeline] withCredentials
Masking supported pattern matches of %GIT_USERNAME% or %GIT_PASSWORD%
[Pipeline] {
[Pipeline] sh
+ git push origin release/test3
Could not create directory '/c/Jenkins/jobs/ssa_mode/workspace/%HOMEDRIVE%%HOMEPATH%/.ssh'.
percent_expand: unknown key %H
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
请帮助解决问题。
答案 0 :(得分:0)
sh()
中的Jenkinsfile
步骤适用于Linux代理。由于您是在Windows代理上运行此命令,因此将所有出现的sh()
替换为bat()
,以适当地扩展变量%HOMEDRIVE%%HOMEPATH%
。