I connect to perforce via ssh, and have a key prepared for this purpose. The key is loaded in as a credential but when using BOTH ssh-agent-plugin and perforce-plugin, the perforce command fails to sync the workspace with the error:
[workspace] $ p4 -s client -i
Caught exception communicating with perforce. TCP receive failed. read: socket: Connection reset by peer
For Command: p4 -s client -i
When using ssh-agent-plugin in conjunction with the build step "execute shell", a command "ssh-add -l" lists the expected credentials, and "p4 info" command is able to connect to the server, so the ssh-agent-plugin is doing the right thing in the context of the build step itself, just not the source code checkout portion!
As a work around, I have added the -i /path/to/key/file option into my p4port. The p4port was something like "rsh:ssh -q my.perforce.host" now it is "rsh:ssh -i ~jenkins/.ssh/key_path -q my.perforce.host". This workaround is successful for now.
I don't know if this is a problem with perforce or ssh-agent plugin.