question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting "Detached head" error in Azure Pipeline build

See original GitHub issue

Hi,

I was trying to improve our Azure Pipeline yaml to handle the preparation to a new release right on the build. For that I added this on a PS step: nbgv prepare-release

Upon execution it fails with this: Detached head. Check out a branch first.

I’ve cloned the repo locally and tried that on a PowerShell console without any issues and getting the expected outcome: a new branch and the current version config bumped.

Any ideas on what am I missing here?

Thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
AArnottcommented, Sep 17, 2019

I think your failure is because ps1 considers the entire env var to be a single argument instead a string of space delimited arguments. Powershell has a syntax or two to support what you’re trying to do but I can’t remember them off-hand.

1reaction
josesimoescommented, Sep 17, 2019

@ap0llo you correct! I’ve tried to do that git checkout without success. For some reason, it doesn’t like to “checkout” on a detached head…

I ended up cloning the repo to the Pipeline temp folder and call nbgv on that one to do the prepare-release. All this is in PowerShell script.

Something curious that I couldn’t find a way through: I’m not able to pass parameters to the tool using an Azure Pipeline variable. My idea was to have a pipeline var, like NbgvParameters. With the default being an empty string. The call to the tool in the PS1 is (was): nbgv prepare-release $env:NbgvParameters

Couldn’t make is work because nbgv always complained about the parameters with: error: invalid option --versionIncrement build

I tried several variations: with double quotes on the full line, double quotes just on the variable, single quotes. Nothing seemed to work…

If this is of interest to anyone the Azure Pipeline is here. Look for the failed jobs from yesterday and specifically the “NBGV prepare release” step.

Thanks anyway! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure DevOps/VSTS always reports "DETACHED HEAD" ...
Guess, what, Azure Devops always complains that it has "DETACHED HEAD" , at every build execution. Note the following from "Checkout" phase:
Read more >
Detached head while building on Azure DevOps
I notice the following during the pipeline build stage for my git branch. I however get no 'HEAD DETACHED' error when I checkout...
Read more >
YAML build pipelines with detached head and pushing tags
My current thinking is clean the work space out in the first step, manually clone the repo and checkout the branch the pipeline...
Read more >
Detached Head while building pipeline on Azure DevOps
It is an expected behavior, a kind of temporary Git state. For our project it corrupted the build info we keep in binary,...
Read more >
Pipeline options for Git repositories - Azure
In this article. Branch; Clean the local repo on the agent; Label sources; Report build status (Azure Pipelines, TFS 2018 and newer) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found