【问题标题】:Azure DevOps/VSTS always reports "DETACHED HEAD" on a clean repositoryAzure DevOps/VSTS 总是在干净的存储库上报告“DETACHED HEAD”
【发布时间】:2019-02-05 06:25:56
【问题描述】:

朋友们,

我现在厌倦了 Azure DevOps/VSTS。 Jenkins 好多了,现在仍然如此,只是我的组织想要使用 Azure DevOps。

我有一个谜团需要帮助解决。

以下是我笔记本电脑上的 repo,它没有未跟踪或未提交的更改。

git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

git remote -v
origin  https://github.com/xxx/terraformvsts.git (fetch)
origin  https://github.com/xxx/terraformvsts.git (push)

猜猜看,Azure Devops 在每次构建执行时总是抱怨它有 "DETACHED HEAD" 。

请注意“结帐”阶段的以下内容:

2019-02-05T05:55:33.2076875Z Note: checking out 'aad90fceecf39a7731c356ebfe2b547ddbce99e6'.
2019-02-05T05:55:33.2076992Z 
2019-02-05T05:55:33.2077872Z You are in 'detached HEAD' state. You can look around, make experimental
2019-02-05T05:55:33.2077939Z changes and commit them, and you can discard any commits you make in this
2019-02-05T05:55:33.2078179Z state without impacting any branches by performing another checkout.
2019-02-05T05:55:33.2078345Z 
2019-02-05T05:55:33.2078389Z If you want to create a new branch to retain commits you create, you may
2019-02-05T05:55:33.2078683Z do so (now or later) by using -b with the checkout command again. Example:
2019-02-05T05:55:33.2078717Z 
2019-02-05T05:55:33.2078933Z   git checkout -b <new-branch-name>
2019-02-05T05:55:33.2078966Z 
2019-02-05T05:55:33.2079004Z HEAD is now at aad90fc Clean Repository

Build pipeline 的 checkout 阶段如下:

如何解决这个问题?我不应该结帐吗?还是应该修改构建管道中的配置设置之一?

【问题讨论】:

  • 就像答案一样,这是 Azure DevOps 构建的行为。问题是什么?为什么对你不好?
  • 我也不喜欢。它不直观,一些合作伙伴也不知道这一切,也不灵活。微软的方式很复杂,而且充满了不必要的步骤。更不用说高级的东西仅限于它们的外壳,它只能在 Windows 上运行。

标签: git github azure-devops


【解决方案1】:

这就是 Azure DevOps Pipelines 的设计方式。

如果您仍然需要签出“那个”分支(或任何其他特定分支),您可以添加一个任务:

- task: CmdLine@2
  displayName: Checkout $(Build.SourceBranchName)
  inputs:
    script: 'git checkout $(Build.SourceBranchName)'

【讨论】:

【解决方案2】:

这不是抱怨,这就是 Azure DevOps 的工作方式。我在所有版本和所有 repos 上都看到了。没有错。

【讨论】:

  • @Edward Thomson,注意到您将 ADO 的此答案编辑为 Azure DevOps。如果不是 ADO,是否还有其他一些微软更喜欢我们使用的缩写名称?当它是 Visual Studio Team Services 时,通常很容易在对话中使用 VSTS,但在随意的对话中称它为“Azure DevOps Server”有点太罗嗦了。
  • 我认为 ADO 是它的“标准”名称
  • 不,我们没有“Azure DevOps”的缩写——“ADO”之类的东西令人困惑,因为已经有一个“ADO.net”。但是“Azure DevOps”与“VSTS”的音节数相同。 耸耸肩
  • 人们会缩短它,不管你喜欢与否,你猜怎么着,没有人会称之为 devops ;) @EdwardThomson
  • 确实,我无法阻止人们。不,没有人应该称它为“DevOps”。但值得一提的是,我们用自己的名字来称呼不同的产品。我们不在“Azure DevOps”中构建,我们在 Azure Pipelines(或者,是的,只是 Pipelines)中构建。当我们谈论完整套件时,我们真的只谈论 Azure DevOps。
【解决方案3】:

要签出源分支,请运行以下步骤:

- script: |
    source=$(Build.SourceBranch)
    git checkout ${source#"refs/heads/"}

git name-rev --name-only $(Build.SourceBranch) 的解决方案对我不起作用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-19
    相关资源
    最近更新 更多