Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the execute shell command in Jenkins to run git commands on a Windows machine

I need to run a bash script that periodically deletes old git branches. I am having trouble finding a way to connect to the git repo via the execute shell option.

Currently I am using cygwin in order to run git commands. Here is what I have in execute shell:

#!c:\cygwin64\bin\bash --login
git ls-remote [email protected]:/external-web/collette-com.git 

This command is throwing the following error.

[Delete Branches] $ c:\cygwin64\bin\bash --login 

C:\Users\tbraga\AppData\Local\Temp\hudson5750784484659728632.sh
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Build step 'Execute shell' marked build as failure

I have tried running this command in the command line and am prompted for a password. Could this be the issue?

I have the git plugin configured within Jenkins and the connection works perfectly when using Source Code Management Git.

Any suggestions on how to make this connections work in the execute shell field would be greatly appreciated.

like image 528
mloomis Avatar asked Nov 09 '22 21:11

mloomis


1 Answers

I solved this problem by passing my credentials to my execute shell script through the Credentials Binding Plugin in Jenkins

like image 199
mloomis Avatar answered Nov 14 '22 21:11

mloomis