Jenkins 变量取值问题,for取值在ssh远端命令中不生效

错误用法

#!/bin/sh

echo ${ServerParam}
echo ${PushParam}

# for取值在ssh远端命令中不生效
ssh root@192.168.130.86 "cd /root/app/release/make/;for dir in ${ServerParam}; do echo "${dir} =="; cd ${dir}; pwd; ls; sh -x ./release.sh-jenkins ${PushParam}; cd ..;done"

正确的用法

#!/bin/sh

for dir in ${ServerParam}; do
    workdir=/root/app/release/make/${dir}
    echo "workdir:$workdir"
    result=`ssh root@192.168.130.86 "cd $workdir; sh -x ./release.sh-jenkins ${PushParam}"`
done
posted @ 2021-10-14 13:51  flytoyou  阅读(183)  评论(0编辑  收藏  举报