You can use something like this:
This mechanism help you do any ssh related task. Where 'ssh_key_file' is
secrete file base credentials.
def runShellwithCredentials(ssh_key_file,cmd) {
env.RUN_CMD = cmd
try {
withCredentials([[$class: 'FileBinding', variable: 'PVT_KEY_FILE',
credentialsId: ssh_key_file]]) {
sh '''
chmod 0500 $PVT_KEY_FILE
env
eval `ssh-agent`
ssh-add $PVT_KEY_FILE
$RUN_CMD
kill -s term $SSH_AGENT_PID
'''
}
} catch (e) {
def w = e.printStackTrace()
mailSubject += " has failed with ${e.message}"
mailBody += mailSubject
mailer(mailSubject,mailBody)
throw e
}
}
On Sunday, May 10, 2015 at 2:10:45 AM UTC-4, lfast wrote:
>
> I'm getting lost in the number of different ways to integration Jenkins &
> Puppet. What I'm looking for should be simple: From Jenkins, execute
> puppet agent/apply on a remote server.
>
> I'm currently using the SSH plugin to run puppet on the remote server.
> I'm just starting to look at the Workflow system but as yet haven't found
> the syntax for using the SSH plugin in a Workflow or anything equivalent.
>
> I also recognize that the core issue here is managing authentication onto
> the remote server. Are there any 'best practices' for this? General
> recommendations or even 'this worked for me' would also make me happy.
>
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/479ed936-bc43-43bd-9859-b3300cf3add9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.