我试图用jenkins做一个定制的docker文件。我会等到8080端口打开,而不是用netcat做一个丑陋的“睡眠60”,但对bash脚本和netcat不太自信。
这是我正试图做的一个例子:
#!/bin/bash opened=0 while [ "$opened" == "0" ]; do echo "Waiting jenkins to launch on 8080..." nc -vz localhost 8080 done echo "Jenkins launched"
您不能将netcat设置为等待某个端口打开,因此您必须在进行下一次检查之前添加等待的部分。尝试这个:
原文链接:https://www.f2er.com/bash/387283.html#!/bin/bash echo "Waiting jenkins to launch on 8080..." while ! nc -z localhost 8080; do sleep 0.1 # wait for 1/10 of the second before check again done echo "Jenkins launched"