0

How to automate these commands in windows. Answer could be obvious ".bat" file.

sample.bat

C:\Program Files\Git\git-bash.exe
cd c:\directory\
eval $(ssh-agent -s) && ssh-add "id_rsa"
git clone repo

By doing this, a new bash window opens but i don't see these commands executing there.

And also, how do i do this via jenkins as well (On windows slave) ?

Answer (As suggested by poke): Passing multiple arguments as well.

git-bash.exe -c "cd /c/dictionary; eval $(ssh-agent -s) && ssh-add 'id_rsa'; git clone repo"
Jackie
  • 129
  • 17
  • @Andras Deak : Have you gone through the question correctly ? Have you tried the above commands ? Did you try the same process on jenkins as well ? Marking as duplicate is very easy without any solution. Could you please help me here. – Jackie Aug 05 '17 at 16:57
  • 1
    *I* did mark it as a duplicate, not Andras. And if you go through the linked question, you should get enough ideas on how to run an arbitrary list of commands automatically using Git bash. – poke Aug 05 '17 at 17:07
  • @Andras Deak : I apologize. Poke : I tried possible batch file ways, but didn't workout. Looks like I'm missing something. How to execute bash mode on windows slave machine from jenkins ? How to write batch file for above scenario ? Could you help me here ? – Jackie Aug 05 '17 at 17:16
  • As explained in the linked question, you use the `-c` argument to pass commands to `git-bash.exe`, or even run a bash file that way. – poke Aug 05 '17 at 17:18
  • @Poke : how do i pass these 3 different commands ? 1)cd c:\directory\ 2)eval $(ssh-agent -s) && ssh-add "id_rsa" 3)git clone repo – Jackie Aug 05 '17 at 17:49
  • 1
    `git-bash.exe -c "cd /c/dictionary; eval $(ssh-agent -s) && ssh-add 'id_rsa'; git clone repo"` – poke Aug 05 '17 at 17:52

0 Answers0