I have a script for Jenkins Pipeline plugin. I already did git clone and maven build. But I have problems with transferring *.jar file to remote server. In Jenkins settings, I already have added configuration for a remote server using ssh key. And it works fine.
But I can't understand how to use these settings in the pipeline script. I googled an example:
sshagent(['8e9cc002-f19dewiydtwe765-ecec834']) {
sh "ssh user@server \"echo ${env.BUILD_ID}\""
}
but I can't understand where this credentials id 8e9cc002-f19dewiydtwe765-ecec834. I can use it in other Jenkins item in section Send files or execute commands over SSH - just choose credentials from the dropdown. How to configure pipeline to use this credentials (key, passphrase, username, server address etc)?