Getting "Detached head" error in Azure Pipeline build
See original GitHub issueHi,
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:
- Created 4 years ago
- Comments:8 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
@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! 😃