I'm using Jenkins' Publish Over SSH Plugin to transfer the same set of files to a group of hosts and then run a small script there. Using the "add server" feature however requires me to repeat source files, remote directory and exec command for every additional server.


What I'm looking for is a way to specify a list of ssh servers for which the plugin should be executed, preferably in parallel, though the number of servers (4-12) is small enough for a sequential flow too.

Some project specific context:

  • The publish task is to transfer a JMeter server to a number of load generators and start it there
  • It is part of the "Build Environment" section right now because the actual build is the execution of the JMeter scenario. If it makes more sense to move any of these steps to a different section, I'm open to that.

Thanks in advance for suggestions.

  • 1
    Have you tried using Jenkins Job Builder or configuration management (e.g. Chef, Puppet) to generate your job configs? – jayhendren Sep 29 '17 at 23:52
  • Going to look at these tools, thanks for the suggestion. – Christian Oct 6 '17 at 13:40

You can also configure an "Execute shell" block and run there something like:

for server in $(cat $LISTFILE); do 
  pssh -i -p $SESSIONS -O ConnectTimeout=$TIMEOUT -h $LISTFILE "$COMMANDS"

pssh is a free parallel ssh client, more information can be found here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.