简体   繁体   中英

Jenkins - execute script on different machine with local env variables

Have:

  1. Jenkins job that needs to execute bash command and initialise variable locally:

    GOOD_VARIABLE= command

  2. SSH into remote host and execute another command with above variable

    command ${GOOD_VARIABLE}...

Problem:

I know how to ssh into another machine and execute command there but how can I pass that local variable to remote host?

Tried but didn't work:

  • Pre build script
  • Inject environment variables to the build process

sounds like your problem is how to send a var through SSH.

You have a detailed answer there: https://unix.stackexchange.com/questions/299037/pass-variable-in-ssh

Don't forget the -T when using SSH through Jenkins!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM