我对将分支名称作为字符串传递给我的代码有疑问。
所以我们使用的是 git 存储库,分支号也指的是放置构建的暂存环境。意思是,如果我的分支是 001,我的 url 是 001.test.myapplication.com。
我正在编写在分支的暂存环境中执行的自动化测试。我的问题是,是否可以将分支编号传递给我的代码,以便我可以将其作为我要测试的 URL 的一部分?
我正在使用 visual studio 2017、selenium 和 specflow。
最佳答案
我实际上找到了一个完美的解决方案。分享出来,以后有需要的人也可以用。
ProcessStartInfo startInfo = new ProcessStartInfo("git.exe");
startInfo.UseShellExecute = false;
startInfo.WorkingDirectory = "dir Here";
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardOutput = true;
startInfo.Arguments = "rev-parse --abbrev-ref HEAD";
Process process = new Process();
process.StartInfo = startInfo;
process.Start();
string branchname = process.StandardOutput.ReadLine();
关于c# - 将分支名称获取到代码中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48421697/