其他分享
首页 > 其他分享> > Jenkins 变量取值问题,for取值在ssh远端命令中不生效

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

标签:workdir,cd,sh,ssh,Jenkins,echo,取值,dir
来源: https://www.cnblogs.com/netflix/p/15406388.html