4
votes

Friends,

I am now getting tired of Azure DevOps/VSTS. Jenkins was much better and still is, just my organization wants to use Azure DevOps.

I have a mystery which I need assistance to solve.

The following is the out of my repo from my laptop, it has no untracked or uncommitted changes.

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)

Guess, what, Azure Devops always complains that it has "DETACHED HEAD" , at every build execution.

Note the following from "Checkout" phase:

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

The checkout phase for Build pipeline is like below:

enter image description here

How to resolve this issue? should I not do checkout? or one of the config settings in the Build pipelines should be amended?

3
Like the answer, this is the behavior of Azure DevOps builds. what is the issue? why is not good for you?Shayki Abramczyk
I don't like it either. It's not intuitive, neither some partners know it all and it's not flexible.The Microsoft way is complex and full of unnecessary steps. Not to mention that advanced things are restrict to their shell, which only runs on Windows.Paulo Pedroso

3 Answers

9
votes

This is how Azure DevOps Pipelines is designed.

If you still need to checkout "that" branch (or any other specific branch), you can add a task:

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

It's not complaining, this is how Azure DevOps works. I see on all builds, on all repos. nothing is wrong.

0
votes

To checkout the source branch, run this step:

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

A solution with git name-rev --name-only $(Build.SourceBranch) did not work for me.