我有一个运行ssh-add的脚本。
通过命令行执行时,脚本可以由root用户正常运行。
通过命令行执行时,该脚本可与jenkins用户一起正常运行。
通过jenkins build执行时,脚本确实失败。
脚本:
PASS="MYPASS"
install -vm700 <(echo "echo $PASS") "$PWD/ps.sh"
[[ -z "$DISPLAY" ]] && export DISPLAY=:0
< ../ssh/pk SSH_ASKPASS="$PWD/ps.sh" ssh-add - && shred -n3 -uz $PWD/ps.sh
通过命令行执行时的日志:
[root@machine xxx-datalake-dataflow]# ./unlock_ssh.sh
‘/dev/fd/63’ -> ‘/usr/src/user_dev/xxx-datalake-dataflow/ps.sh’
Identity added: (stdin) (email)
通过詹金斯执行时的日志:
+ cd /usr/src/user_dev/xxx-datalake-dataflow
+ ./unlock_ssh.sh ****
./unlock_ssh.sh: line 2: syntax error near unexpected token `('
./unlock_ssh.sh: line 2: `install -vm700 <(echo "echo $PASS") "$PWD/ps.sh"'
Build step 'Execute shell' marked build as failure
Finished: FAILURE
jenkins的构建说明:
cd /usr/src/user_dev/xxx-datalake-dataflow
./unlock_ssh.sh $ADDSP
为什么通过jenkins build运行它会失败,以及如何解决?