我试图使用GitAliases从Jenkins上的蛋糕脚本中对Git进行一些修改。我克服了文档(https://cakebuild.net/api/Cake.Git/GitAliases/)中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()推送标记,但没有成功。我可以看到提交在本地成功,标记被创建,但是Push总是失败。我遇到的最常见的错误是:
错误:出现一个或多个错误。不支持的URL协议
Git用户帐户使用SSH。
发布于 2019-08-22 16:18:24
蛋糕Git使用libgit2sharp进行git操作,它不支持SSH。
在libgit2sharp GitHub回购https://github.com/libgit2/libgit2sharp/issues/1422上有一个公开的问题
https://stackoverflow.com/questions/57613043
复制相似问题