Re: Jenkins Pipeline code to run remote shell scripts

2018-09-17 Thread David Karr
On Mon, Sep 17, 2018 at 4:51 AM Arianrhod  wrote:

> Thanks David, I'm sure you're probably right but I've found so many
> different versions of what the 'simple' answer is that I have no real idea
> of the correct syntax for the command.  Referencing credentials that are
> already stored within the Jenkins store, for example; some say this is
> necessary, some say not, and all have different angles on how this should
> be specified.  Even the plugin page isn't really clear on the correct
> syntax, hence my question here.
>

Looking at some old pipeline code of mine, it seems pretty clear that the
"sshagent" wrapper is what you need to use. That takes a "credentials"
property that refers to the credentials object stored in Jenkins, referring
to the private key. Within that block, you can have a "sh" step calling
ssh, which doesn't have to specify any credentials.


> thanks
>
> --
> 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 jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/792f625d-75a5-458e-93b7-4a4233795c92%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8Vqq6bfxg0_a-hudWd0UOkg3opzDC4%2BC_nfO-RSVfx7R6A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Jenkins Pipeline code to run remote shell scripts

2018-09-17 Thread Arianrhod
Thanks David, I'm sure you're probably right but I've found so many 
different versions of what the 'simple' answer is that I have no real idea 
of the correct syntax for the command.  Referencing credentials that are 
already stored within the Jenkins store, for example; some say this is 
necessary, some say not, and all have different angles on how this should 
be specified.  Even the plugin page isn't really clear on the correct 
syntax, hence my question here.

thanks

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/792f625d-75a5-458e-93b7-4a4233795c92%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Jenkins Pipeline code to run remote shell scripts

2018-09-15 Thread David Karr
On Fri, Sep 14, 2018 at 8:49 AM Arianrhod  wrote:

> Hi, I have to run two shell scripts on a remote server as part of a
> pipeline job (scripted, not via the GUI).
>
> They're both run on the same remote server, but one has to run when the
> first finishes, and they run as different users.  There is a 'jenkins' user
> account that has creds in the Jenkins creds store, that has full sudo
> access on all remote servers.
>
> Shell script one has to be run as user abc, shell script two has to be run
> as root.
>
> I have the sshAgent plugin on my Jenkins server, but cannot install any
> new plugins.
>
> Can anyone give me any idea how this can be achieved, please ... I have
> been trawling through endless Google pages for over a week trying to figure
> it out, and drawing a blank.  I'm completely new to scripting jenkinsfiles!
>

I might be missing something simple, but I would think you'd just use the
"sh" pipeline step and run "ssh" with the remote command line to run.


> thanks
>
> --
> 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 jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/859367d8-2038-4ef4-9b7c-c25e9ed12d6a%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAA5t8VofuTAr6K3Y_SQnxWbKhUZLNJKBz%3DssHeUoTmaOOu140g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.