开发者

How do I pass my parameter when trying to execute SSH commands in HUDSON

开发者 https://www.devze.com 2023-02-24 16:46 出处:网络
I want my job to do some commands on other servers.I\'ve created a new (parameterized) job that simply executes shell commands.

I want my job to do some commands on other servers. I've created a new (parameterized) job that simply executes shell commands.

I can't figure out how to get my build parameter to get passed along to the command line of 开发者_Go百科the remote.

ssh myservername 'echo ${MY_PARAMETER}'

Looking at my console output I see:

+ ssh myservername echo ${MY_PARAMETER}

What I want to see is:

+ ssh myservername echo MyValueFromTheBuild

There must be a way to make this happen.


Here's a solution:

bash -c "ssh myservername 'echo ${MY_PARAMETER}'"

Note that here the variable's value on the local machine is used. It won't yield the value of the variable on the remote host. From the context it sounds like the former is what you want.

As ever, be careful not to evaluate input you don't have complete control over.


I use this on our Jenkins server and it works just fine for me.

ssh myservername "echo $PROJECTNAME"


My guess would be to try one of the following syntax forms:

ssh myservername 'echo $MY_PARAMETER'
ssh myservername 'echo ${ENV, var="MY_PARAMETER"}'
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号