无法在 cake 脚本中成功执行 GitPush 或 GetPushRef
Unable to successfully perform GitPush or GetPushRef in cake script
我正在尝试使用 GitAliases 从 Jenkins 上的蛋糕脚本对我的 Git 存储库进行一些更改。对于 GitAdd()、GitCommit() 和 GitTag(),现在所有这些都工作成功,但无论我尝试什么,我都无法让 GitPush() 和 GitPushRef() 工作。
#addin "nuget:https://www.nuget.org/api/v2?package=Cake.Git";
using System;
using System.IO;
var gitUserName = Argument("gitUserName","userName");
var gitUserPassword = Argument("gitUserPassword","");
var gitEmail = Argument("gitEmail","some.user@domain.com");
var gitBranchName = Argument("gitBranchName","feature/test-git");
Task("Git:CommitAndPush")
.Does(() =>
{
var rootPath = "./..";
Information($"Commit and Push {rootPath}");
Information("Staging all updated files in /available, /extracted, and /src directories...");
var toAdd = new FilePath[]
{
new FilePath(Path.Combine(rootPath, "available")),
new FilePath(Path.Combine(rootPath, "extracted"))
};
GitAdd(rootPath, toAdd);
Information("Committing files...");
var commit = GitCommit(rootPath, gitUserName, gitEmail, "Commit message");
Information($"Pushing changes for commit {commit}...");
// TODO: Cannot get any of these to work!
//GitPush(rootPath);
//GitPush(rootPath, gitUserName, gitUserPassword);
//GitPush(rootPath, gitUserName, gitUserPassword, gitBranchName);
//var gitTag = "myTag";
//GitTag(rootPath, gitTag);
//GitPushRef(rootPath, "origin", gitTag);
//GitPushRef(rootPath, gitUserName, gitUserPassword, "origin", gitTag);
Information("Git process complete!");
});
我尝试了 GitPush() 和 GitPushRef() 的所有重载,包括创建标签和使用 GitPushRef() 推送标签,但没有成功。我可以看到本地提交成功,并且创建了标签,但是推送总是失败。我遇到的最常见错误是:
“错误:发生了一个或多个错误。
不支持 URL 协议
Git 用户帐户使用 SSH。
Cake Git 使用 libgit2sharp 进行 git 操作,不支持 SSH。
libgit2sharp GitHub 存储库上有一个未解决的问题
https://github.com/libgit2/libgit2sharp/issues/1422
我正在尝试使用 GitAliases 从 Jenkins 上的蛋糕脚本对我的 Git 存储库进行一些更改。对于 GitAdd()、GitCommit() 和 GitTag(),现在所有这些都工作成功,但无论我尝试什么,我都无法让 GitPush() 和 GitPushRef() 工作。
#addin "nuget:https://www.nuget.org/api/v2?package=Cake.Git";
using System;
using System.IO;
var gitUserName = Argument("gitUserName","userName");
var gitUserPassword = Argument("gitUserPassword","");
var gitEmail = Argument("gitEmail","some.user@domain.com");
var gitBranchName = Argument("gitBranchName","feature/test-git");
Task("Git:CommitAndPush")
.Does(() =>
{
var rootPath = "./..";
Information($"Commit and Push {rootPath}");
Information("Staging all updated files in /available, /extracted, and /src directories...");
var toAdd = new FilePath[]
{
new FilePath(Path.Combine(rootPath, "available")),
new FilePath(Path.Combine(rootPath, "extracted"))
};
GitAdd(rootPath, toAdd);
Information("Committing files...");
var commit = GitCommit(rootPath, gitUserName, gitEmail, "Commit message");
Information($"Pushing changes for commit {commit}...");
// TODO: Cannot get any of these to work!
//GitPush(rootPath);
//GitPush(rootPath, gitUserName, gitUserPassword);
//GitPush(rootPath, gitUserName, gitUserPassword, gitBranchName);
//var gitTag = "myTag";
//GitTag(rootPath, gitTag);
//GitPushRef(rootPath, "origin", gitTag);
//GitPushRef(rootPath, gitUserName, gitUserPassword, "origin", gitTag);
Information("Git process complete!");
});
我尝试了 GitPush() 和 GitPushRef() 的所有重载,包括创建标签和使用 GitPushRef() 推送标签,但没有成功。我可以看到本地提交成功,并且创建了标签,但是推送总是失败。我遇到的最常见错误是:
“错误:发生了一个或多个错误。 不支持 URL 协议
Git 用户帐户使用 SSH。
Cake Git 使用 libgit2sharp 进行 git 操作,不支持 SSH。
libgit2sharp GitHub 存储库上有一个未解决的问题 https://github.com/libgit2/libgit2sharp/issues/1422