【问题标题】:Why so many `err:` prefixes in the output of ssh-action even if everything is fine?即使一切都很好,为什么 ssh-action 的输出中有这么多 `err:` 前缀?
【发布时间】:2021-06-12 23:20:00
【问题描述】:

我在appleboy/ssh-action 上,我有一个非常简单的步骤

steps:
  - name: execute remote commands
    uses: appleboy/ssh-action@master
    with:
      host: ${{ secrets.HOST }}
      username: ${{ secrets.USERNAME }}
      key: ${{ secrets.KEY }}
      port: ${{ secrets.PORT }}
      script: |
        echo "Go to the project space"
        cd $HOME/actions_workspace/actions-sample
        echo "Pulling the repo from the remote server"
        git pull origin main
        echo "Building the new container"
        docker-compose build

它工作正常,但这是输出:

======CMD======
echo "Go to the project space"
cd $HOME/actions_workspace/actions-sample
echo "Pulling the repo from the remote server"
git pull origin main
echo "Building the new container"
docker-compose build

======END======
out: Go to the project space
out: Pulling the repo from the remote server
err: From github.com:floatingpurr/my-test-repo
err:  * branch            main       -> FETCH_HEAD
err:    3961b2c..26e6abe  main       -> origin/main
out: Updating 3961b2c..26e6abe
out: Fast-forward
out:  README.md          |  2 +-
out:  docker-compose.yml | 12 ++++++------
out:  2 files changed, 7 insertions(+), 7 deletions(-)
out: Building the new container
err: my-test-actions uses an image, skipping
==============================================
✅ Successfully executed commands to all host.
==============================================

我只是想知道为什么我在操作输出中看到 err: 前缀,而不仅仅是 out:(正如我所料),因为一切都很好。

【问题讨论】:

  • 我怀疑这意味着git 将这些消息打印到stderr 而不是stdout
  • 哦,真的吗?看起来 docker-compose 也是如此……它“正常”吗?

标签: bash ssh github-actions


【解决方案1】:

正如我mentioned here 一样,任何不被机器消费的信息性消息都将被路由到 stderr。
作为illustrated here

详细的状态和进度报告,尤其易于阅读 那些,应该总是去stderr。

如果你真的需要,你可以redirect stderr to stdout,但这里不需要。

【讨论】:

  • 感谢您指出这一点。我猜这种行为不会影响退出代码......
  • @floatingpurr 不,它没有。
猜你喜欢
  • 2023-02-04
  • 1970-01-01
  • 1970-01-01
  • 2019-11-14
  • 2014-09-17
  • 2011-05-22
  • 1970-01-01
  • 1970-01-01
  • 2014-12-19
相关资源
最近更新 更多