Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins execute shell scripts with parameters on remote machine

I have a Jenkins job which executes a shell script on remote server. Now I would like to send some parameters along with the shell script. Below example might get you more idea.

variable1={git-URL}
variable2={branch}

I want this parameters to be passed on to shell script which is on remote machine and should execute like below

#/usr/local/bin/check_out_code.sh <git-url> <branch>

Would be great if anyone can point me some work around for this

Thanks.

like image 528
Swaroop Kundeti Avatar asked May 29 '26 10:05

Swaroop Kundeti


2 Answers

You can reference any environment variable, including Jenkins parameters, as any other variable in linux: ${VARNAME}

like image 108
Slav Avatar answered May 31 '26 06:05

Slav


I have the same problem with it.

The parameters/${xx}/$xxx are undefined in remote machine. So when your shell script executes in remote machine cannot get the correct value.

This way will fix the problem:

ssh -t server.example.com 'export MYVAR='"'$LOCALVAR'"'; mycommand'
like image 27
Janus Wen Avatar answered May 31 '26 06:05

Janus Wen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!