Skip to content

Build fails with [ Could not inject value for "Build.GitVersion" ] but only when ran in Azure DevOps pipeline #1013

Answered by bhehe
bhehe asked this question in Q&A
Discussion options

You must be logged in to vote

The root-cause of this ended up being like the related story, the FetchDepth issue is the main reason.

Turns out that any net-new Build Pipelines created in DevOps is now using the 'Shallow Fetch' option enabled with a depth of 1. This explains why doing what we did before (that still works) doesn't work for any new build pipelines we create. MSFT has changed the defaults it appears.

In your build pipeline, if you select Edit >> Triggers >> YAML and then select the 'Get Sources' step you'll see this option named 'Shallow Fetch' and it being defaulted to Enabled with a Depth of 1. Once I disabled it then everything magically started working.

Hopefully sharing this info saves someone else s…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@rena0157
Comment options

@kornelijepetak
Comment options

@valadas
Comment options

@igiona
Comment options

Answer selected by bhehe
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants
Converted from issue

This discussion was converted from issue #1012 on September 12, 2022 20:48.