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.
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();
Answered By – Anand