Can't use redirections in a shell command stored in a string

时间:2016-10-04 14:44:01

标签: bash io-redirection

I have the following code in Jenkins "Execute shell"

command="curl -H \"X-HockeyAppToken:${!HOCKEYAPP_TARGET_TOKEN}\" ${HOCKEYAPP_SERVER_API}/apps/${!HOCKEYAPP_TARGET_ID}/app_versions?include_build_urls=true 2>/dev/null"
echo "$command"
test=$($command)

The echo prints something like:

curl -H "X-HockeyAppToken: 1234567890abcdef1234567890abc" https://hockeyapp.example.com/api/2/apps/ccc1234567890abcdef1234567890/app_versions?include_build_urls=true 2>/dev/null

If I copy the curl command line into the shell, it works fine.

However, I get the following error in Jenkins:

curl -H "X-HockeyAppToken: 1234567890abcdef1234567890abc" https://hockeyapp.example.com/api/2/apps/ccc1234567890abcdef1234567890/app_versions?include_build_urls=true 2>/dev/null: No such file or directory

Where is that "2>/dev/null: No such file or directory" is coming and why is that interpreted that way?

0 个答案:

没有答案