飞天使-jenkins进行远程linux机器修改某个文件的思路

jenkins配置的方式

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

jenkins中执行shell的思路


下面的脚本别照抄,只是一个思路
ipall="$ips"

# 将文本参数按行输出为变量
while IFS= read -r line; do
    echo "$line"
if [[ ! -z $line ]] && [[ $add == 'true' ]];then
for ip in ${line[@]}
do
    ssh [email protected] "echo $ip "
    ssh [email protected] "echo $ip >> /tmp/deny_ip.cl"
done
elif [[ ! -z $line ]] && [[ $remove == 'true' ]]; then
 
    echo "remove"
    #d=$(echo $ip |sed 's,/,\\/,g')
for ip in ${line[@]}
do
    d=$(echo $ip )
    echo $d
    ssh [email protected] "sed -i '/^$d$/d' /tmp/deny_ip.cl"
    #ssh [email protected] "sed -i 's@\<$d\>@en@d' /tmp/deny_ip.cl"
done
elif [[ $check == 'true' ]]; then 
   ssh [email protected] "cat /tmp/deny_ip.cl"
else
  echo "notgood"
fi
done <<< "$ipall"

猜你喜欢

转载自blog.csdn.net/startfefesfe/article/details/132296911