I created a job in jenkins where it pulls the source code from a private repo in bitbucket using ssh keys. So I had to set it up using PUTTY and set an environment variable GIT_SSH to the plink location. So when I pull from the command line, it works fine. Now when I add the bitbucket Repository URL with the credentials, where I added the private key, before I even click on save, it shows an error message
Failed to connect to repository : Command "C:\Program Files\Git\bin\git.exe ls-remote -h repo link. return status code 128. tdout: stderr: Load key "C:\\Windows\\TEMP\\ssh2792596192881196946.key": invalid format [email protected]: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. I am not sure why it's giving this message. So I thought of trying it another way where I created a batch file that pulls my repo. From command line, it works fine, but when I add the batch file to Jenkins job, it gives an error:
[email protected]: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. I thought since it works on the command line, if I just add the location of the batch file to jenkins and let it execute it, it should work, but it doesnt.