Reputation: 3015
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)?
Upvotes: 3
Views: 9845
Reputation: 5319
That credential ID is specified manually when you create a credential, or Jenkins will build a big ugly one like that for you if you don't. You can see the ID back on the credentials page.
I always manually assign an ID so I don't have to work with those ugly ones, and so that it is a little more self-documenting in a jenkinsfile.
Upvotes: 4