记一次jenkins发生的无法判断字符串前后空格

 

 

 

 

OLD_BUILD_ID=$BUILD_ID
BUILD_ID=dontKillMe
mvn clean package -Dmaven.test.skip=true -U
b=`find . -name ${ser_name}.zip| sed 's/.//'`
if [ -n "$b" ];then echo "ok"; else exit 1;fi && a=$(pwd) && deploy_file=$a$b
ansible-playbook -i /data/XXXX/springcloud.hosts /data/XXXX/springCloud/springCloud_update.yml -v --extra-vars "deploy_file=${deploy_file} host_name=${ansible_host} server_name=${ser_name} dport=${ansible_port}"

OLD_BUILD_ID=$BUILD_ID
BUILD_ID=dontKillMe
mvn clean package -Dmaven.test.skip=true -U
b=`find . -name ${ser_name}.zip| sed 's/.//'`
if [ -n "$b" ];then echo "ok"; else exit 1;fi && a=$(pwd) && deploy_file=$a$b
ansible-playbook -i /data/fs_playbook/inventory/springcloud.hosts /data/fs_playbook/springCloud/springCloud_update.yml -v -e deploy_file="${deploy_file}" -e host_name="${ansible_host}" -e server_name="\"${ser_name}\"" -e dport="${ansible_port}"   传参转义""

上面的红色部分如果为文本参数就无法判断前后位空格  导致无法报错   中间有空间则需要判断字符串为空格的判断,注意jenkins传参建议使用字符参数   还是需要判前后空格

 

posted @ 2021-05-17 11:38  技术颜良  阅读(332)  评论(0编辑  收藏  举报