Unable To Successfully Perform Gitpush Or Getpushref In Cake Script

Business By Jonathan384

Jonathan384 Cake Central Cake Decorator Profile
Jonathan384 Posted 15 Jun 2021 , 10:31am
post #1 of 1

I am attempting to use GitAliases to commit some changes to my Git repo from a cake script on Jenkins. I have been able to overcome the lack of descriptive information and examples for the methods and arguments in the iMessage For Android documentation  for GitAdd(), GitCommit(), and GitTag(), all of which are working successfully now, but I am not able to get GitPush() nor GitPushRef() to work no matter what I try.

#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","[email protected]"); 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!"); });

I have tried every overload of GitPush() and GitPushRef() including creating a tag and pushing the tag using GitPushRef() but no luck. I can see the commit is successful locally, and the tag gets created, but the Push always fails. The most common error I am getting is:

"Error: One or more errors occurred. unsupported URL protocol"

The Git user account uses SSH.

0 replies

Quote by @%username% on %date%