Git jenkins scm plugin permission denied

When I try to configure the task to build the project from the git repository, I get an error:

Failed to connect to repository : Command "git ls-remote -h ssh:// git@ssh :// git@host.com /path/to/repos.git HEAD" returned status code 128: stdout: stderr: Permission denied (publickey). fatal: The remote end hung up unexpectedly 

In Jenkins, I installed the SSH agent plugin and git plugin.

I can add a build step with the following:

 git ls-remote -h ssh:// git@host.com /path/to/repos.git HEAD 

Run the build and it works!

This tells me that everything is configured correctly:

  • Keys and key layout.
  • Jenkins / Jenkins Management / Plugin Management β†’ SSH Agent Plugin and git plugin.
  • Jenkins / Manage Jenkins / Manage Credentials entry is correct.

This does not seem to work for source control, but for the pre-build / build / post-build operation it does.

Is there a problem with the Ssh agent not being activated before the build process?

Thanks in advance to everyone who can help.

+4
source share
1 answer

"Is there a problem with the SSH agent not being activated before the build process?" - Yes, and it is annoying.

I read β€œsomewhere” on my hunt that they plan to make the SSH agent in git and other plugins correct in the future.

If you run a simple shell command with the SSH agent setup, you will see that it starts and stops before and after the shell command at the console output for the assembly, this does not happen when git data is entered.

Just keep using the build steps as described now ...

+2
source

All Articles