Pseudo-terminal will not be allocated because stdin is not a terminal.|gitlab ssh问题记录

转自 http://blog.c7d8.com/blog/7.html,原文可能有更新,以原文为准
今晚下班前发布版本,测试已做最后的回归且通过,眼看就能发布上线等验证通过就下班。但发布过程中出现问题,具体问题如下

Running with gitlab-runner 11.6.0 (f100a208)
on stg deploy runner 906e1b780
Using SSH executor…
Running on to-deploy.cloudq.com via to-deploy.cloudq.com
Fetching changes…
Removing business-service.jar
Removing dist.tar.gz
Removing dist/
Removing pftal-web.jar
Removing sustem.jar
Removing syrvice.jar
HEAD is now at 56a20d5 Merge branch ‘dev’ into ‘master’
Checking out 56a20d59 as V1.8.0.3(3.18) …
Skipping Git submodules setup
Downloading artifacts for maven (69655)…
Runtime platform arch=amd64 os=linux pid=2382 revision=f100a208 version=11.6.0
Downloading artifacts from coordinator… ok id=69655 responseStatus=200 OK token=Cp84P5Q_
Downloading artifacts for node (69657)…
Runtime platform arch=amd64 os=linux pid=2399 revision=f100a208 version=11.6.0
Downloading artifacts from coordinator… ok id=69657 responseStatus=200 OK token=Cp84P5Q_
$ ssh $NGINX_REMOTE “sh $UPLOAD_PATH/cloudqq_web_backup.sh chengdu”
Pseudo-terminal will not be allocated because stdin is not a terminal.
could not connect to remote: dial tcp: address tcp//adfasdfasd/stg/uploads/cloudqq_web_backup.sh: unknown port
ssh_exchange_identification: Connection closed by remote host
ERROR: Job failed: Process exited with: 1. Reason was: ()

根据错误记录

Pseudo-terminal will not be allocated because stdin is not a terminal.

第一时间百度,出来的是要加-T或者-tt,尝试依然无效,遂将排查点放到了错误的语句本身

$ ssh $NGINX_REMOTE “sh $UPLOAD_PATH/cloudqq_web_backup.sh chengdu”
could not connect to remote: dial tcp: address tcp//adfasdfasd/stg/uploads/cloudqq_web_backup.sh: unknown port

那是不是变量没有加载出来呢?
于是在gitlab-ci.yml中执行ssh之前增加一条echo输出看看就知道了
果然没有获取到该变量的值!!

Pseudo-terminal will not be allocated because stdin is not a terminal.|gitlab ssh问题记录
看到这个变量是存在的?为什么这个的保护状态是开启的?仔细看相应的提示发现,被保护的变量只有在被保护的tag和分支下可以读取到,但我们发布的tag是v开头的被保护tag啊!
Pseudo-terminal will not be allocated because stdin is not a terminal.|gitlab ssh问题记录

再看看我们的tag命名
Pseudo-terminal will not be allocated because stdin is not a terminal.|gitlab ssh问题记录

我擦!我们保护的小写v开头的tag,但是我们打tag的同学是用V命名开头的
再检查以前类似失败的tag,都是不符合被保护tag的特征,所以失败了!
吃一斤长一斤啊!!!!