Bash 从jenkins调用的Minicom脚本在退出时失败';!killall-9迷你通信';

Bash 从jenkins调用的Minicom脚本在退出时失败';!killall-9迷你通信';,bash,jenkins,serial-port,gnu-screen,Bash,Jenkins,Serial Port,Gnu Screen,我设法制作了一个脚本,通过minicom发送一些命令,并将它们存储在output.txt上。调用minicom的脚本称为dut.sh #!/bin/bash echo "Setting up DUT" stm_armv7 -print "DUT" stm_armv7 -dut echo "wait 30s" sleep 30s stty -F /dev/ttyACM0 115200 cs8 -cstopb -parenb rm /

我设法制作了一个脚本,通过minicom发送一些命令,并将它们存储在output.txt上。调用minicom的脚本称为
dut.sh

#!/bin/bash

echo "Setting up DUT" 
stm_armv7 -print "DUT"
stm_armv7 -dut
echo "wait 30s"
sleep 30s

stty -F /dev/ttyACM0 115200 cs8 -cstopb -parenb
rm /home/fsnk/scripts/serial-com/output.txt
export TERM=linux-c-nc
minicom -b 115200 -D /dev/ttyACM0 -C /home/fsnk/scripts/serial-com/output.txt -S /home/fsnk/scripts/serial-com/serial -o 
echo "wait another 5s"
sleep 5s
stm_armv7 -ts 
minicom
命令中,我给出了另一个名为just
serial
的文件,其中包含一些runscript代码

# UNIX login script.
# Can be used to automatically login to almost every UNIX box.
#
# Some variables.
set a 0
set b a
print Trying to Login..
# Skip initial 'send ""', it seems to matter sometimes..
send ""
goto login

login:
if a > 3 goto failed1
expect {
    "ogin:"       send "root"  
    "assword:"    send ""
    timeout 5    goto loop1
   
}
goto loop1

loop1:
send "systemctl is-system-running --wait"
sleep 3
# Send command not more than three times.
inc b
if b > 3 goto failed1
expect {
    "\nrunning"    goto success1
    break
    "degrading"  goto success2        
    break
    timeout 5    goto failed2
   
}

success1:    
print \nSuccessfully received running!
! killall -9 minicom
exit

success2:
print \nSuccessfully received degrading!
! killall -9 minicom
exit

failed1:
print \nConnection Failed (wrong password?)
! killall -9 minicom
exit

failed2: 
print \nMessage sending failed. Didn't receive anything!
! killall -9 minicom
exit
命令
!killall-9 minicom
根据其自身功能终止minicom终端。正如我前面提到的,当我在本地运行这个脚本时,或者当我从本地机器通过ssh调用脚本时,它运行正常。当我从詹金斯那里运行这个时,问题就出现了

output.txt文件已创建,但在Jenkins上时仍为空,我收到一条minicom消息,如下所示:

Setting up DUT
wait 30s

Welcome to minicom 2.7

OPTIONS: I18n 
Compiled on Apr 22 2017, 09:14:19.
Port /dev/ttyACM0, 16:30:57

Press CTRL-A Z for help on special keys

/home/fsnk/scripts/serial-com/dut.sh: line 12:  5639 Killed                  minicom -b 115200 -D /dev/ttyACM0 -C /home/fsnk/scripts/serial-com/output.txt -S /home/fsnk/scripts/serial-com/serial -o
wait another 5s

Finished: SUCCESS
在显示消息
后,按CTRL-A Z键可获得有关特殊键的帮助
我希望它登录到板(没有密码,只有root用户)并运行
systemctl is system running-wait
。所有输出必须在output.txt上

同样,当手动运行或通过SSH从我的机器触发时,这与预期的一样有效,但是当从Jenkins触发时(添加了一个构建步骤
executeshell
,它尝试使用SSH并启动脚本),它不起作用


在这一点上,我觉得这是minicom的问题,在这种情况下,我欢迎使用
屏幕

的任何解决方案。我相信这是因为killall导致minicom向操作系统返回错误代码,Jenkins对此进行评估,因此认为它是一个故障。如果这是原因,您可以添加一个try/catch块来标记生成不稳定或成功。

我认为这是因为killall导致minicom向操作系统返回错误代码,Jenkins对此进行评估,因此将其视为失败。你可以添加一个Test/catch块来标记构建不稳定或成功,如果这是原因。

我对詹金斯一无所知,但是如果你建议一个解决方案,考虑添加一些代码。我对詹金斯一无所知,但是如果你建议一个解决方案,考虑添加一些代码。