错误。终端是哑巴,但EDITOR未设置 - BitBucket管道。

问题描述 投票:0回答:1

我第一次使用BitBucket Pipelines来SSH进入开发服务器,并执行一个 git pull origin branch 每当推送到该分支时,都会有一个新的版本。这是相当简单的,一切都在按预期进行.问题出现了,当一个合并沿拉和一个用户输入需要提交合并。在失败的构建日志中,我得到了以下消息。

 * branch              feature/development -> FETCH_HEAD
d2c27a5f..63d74c8f  feature/development -> origin/feature/development
error: Terminal is dumb, but EDITOR unset
Not committing merge; use 'git commit' to complete the merge.

我只想绕过这个用户输入的要求, 如果有必要的话就提交然后继续. 这是我的构建配置。

image: php:7.1.29

pipelines:
  default:
    - step:
        name: Deploy to dev
        deployment: dev
        # trigger: manual  # Uncomment to make this a manual deployment.
        script:
          - echo "Deploying to dev..."
          - pipe: atlassian/ssh-run:0.2.5
            variables:
              SSH_USER: 'root'
              SERVER: '82.xxx.xx.xx5'
              MODE: 'command'
              COMMAND: 'cd /home/ubuntu/public_html/dev/ && git pull origin feature/development'
         - echo "Deployed!"

我不知道该如何实现这个目标 I haven't the faintest how to achieve this. 任何提示将是巨大的.TIA!

git bitbucket bitbucket-pipelines
1个回答
1
投票

默认情况下,当你进行合并时,Git会尝试调用一个编辑器,这样你就可以编辑提交信息,并以一种有用的方式扩展提交信息。 如果您没有设置编辑器,Git默认为使用 vi.

然而,在非交互式的环境中,Git很清楚地了解到 vi 不工作,因为你没有合适的终端,所以它试图使用 EDITOR 环境变量,它应该可以在哑巴终端中工作,但它没有设置。 (它本来会优先使用它,而不是使用 vi 无论如何,如果它被设置。) 这就是为什么你会收到这样的消息。

如果你不想要这种行为,你可以将环境变量设置为 GIT_MERGE_AUTOEDITno 它就会使用默认值,这可能是你想要的。 如果你想要一些不同的东西,你可以使用 -m 选项,或者你可以指定一个脚本来编辑它,用 EDITOR 环境变量。


1
投票

多亏了 @phd,我可以在合并后立即停止提交,然后使用 -m 选项。

git pull --no-commit && git commit -m "Merge"

我还增加了策略 -x theirs 以确保传入的更改被自动接受。又添加了一些语句,以确保不会丢失任何本地更改,传入的更改不会被优先接受,也不会报告误报。 这是我的配置文件现在的样子。

image: php:7.1.29
pipelines:
    default:
        - step:
            name: Deploy to dev
            deployment: dev
            # trigger: manual  # Uncomment to make this a manual deployment.
            script:
               - echo "Deploying to dev..."
               - pipe: atlassian/ssh-run:0.2.5
                 variables:
                   SSH_USER: 'root'
                   SERVER: '82.xxx.xx.xx5'
                   MODE: 'command'
                   COMMAND: 'cd /home/ubuntu/public_html/dev/ && git add . &&  git commit -a -m "local files server commit" && (echo "OK"; exit 0) || (c=$?; echo "NOK"; (exit 0)) && git pull origin feature/development -X theirs --no-commit && git commit -m "Merge" && (echo "OK."; exit 0) || (c=$?; echo "NOK"; (exit 0))'
               - echo "Deployed!"
© www.soinside.com 2019 - 2024. All rights reserved.