I have a question about passing the branch name to my code as a string.
So we are using a git repository and the branch number also refers to the staging environment where the build is placed. Meaning, if my branch is 001, my url is 001.test.myapplication.com.
I am writing automated tests which are executed on the staging environment of the branch. My question is, is it possible to pass the branch number to my code so I can make it part of the URL I want to test on?
I am using visual studio 2017, selenium and specflow.
Command #1: git branch -r This Git command will show you remote branches. The -r flag here is short for --remotes . This is the command I use personally. So if you want, you can just stop reading here and use git branch -r whenever you want to list remote git branches.
I actually found a great solution which perfectly works. Sharing so in the future, others can use it too if they need to.
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With