1

I am using Jenkins in our builds So I am already using the GIT Plugin This plugin lets me specify Jenkins credentials, where we have already specified and installed/setup SSH keys.

However at the end of the build, I'd like to git tag my repo. I am calling the git.exe command line, and I get this error on a push:

Permission denied (publickey).
fatal: Could not read from remote repository.

Ideally, we don't want to use another plug in, (e.g. Git Publisher), as we are trying to do more of this via our own scripts as there is a good possibility that we may not use Jenkins in the future.

Also, ideally, we don't want to install items on our build server if we don't have to.

So the question is - how can I specify ssh keys/credentials on the command line for the given 'session'?

Thank you.

1
  • Can you add your Jenkins code? Commented Jun 29, 2017 at 17:45

1 Answer 1

1

Put this in a shell script:

ssh -i path-to-your-private-key

Set the path to the shell script in GIT_SSH for Jenkins. git pull will then use that instead of plain ssh to access the remote repository.

Alternately you could configure ssh in $HOME/.ssh for the account under which Jenkins runs, but that can get tricky if your Jenkins runs as a Windows service.

Sign up to request clarification or add additional context in comments.

2 Comments

Yes, it runs as a Windows Service. What is GIT_SSH?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.