Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running build with Nuke 6.2.1 (and 6.1.2) in an Github action on ubuntu-latest fails getting git version information: Could not inject value for "Build.GitVersion" #1008

Closed
ebjornset opened this issue Sep 3, 2022 · 5 comments

Comments

@ebjornset
Copy link

Usage Information

NUKE v 6.2.1 .Net 6.0.400 Github action on ubuntu-latest

Description

After upgrading Nuke.Common from 6.0.3 to 6.2.1 everything worked fine locally on my Windows machine. When I tried to make a Github PR that runs an action on ubuntu-latest the action failed because the call to gitversion.dll that injects value for "Build.GitVersion" fails, and writes this warning to the log

[WRN] Could not inject value for Build.GitVersion
Nuke.Common.Tooling.ProcessException: Process 'dotnet' exited with code 1.
   > /home/runner/.dotnet/dotnet /home/runner/.nuget/packages/gitversion.tool/5.10.3/tools/net5.0/any/gitversion.dll /nocache
   @ /home/runner/work/DryGen/DryGen

   at Nuke.Common.Tooling.ProcessExtensions.AssertZeroExitCode(IProcess process) in /_/source/Nuke.Common/Tooling/ProcessExtensions.cs:line 39
   at Nuke.Common.Tools.GitVersion.GitVersionTasks.GitVersion(GitVersionSettings toolSettings) in /_/source/Nuke.Common/Tools/GitVersion/GitVersion.Generated.cs:line 83
   at Nuke.Common.Tools.GitVersion.GitVersionTasks.GitVersion(Configure`1 configurator) in /_/source/Nuke.Common/Tools/GitVersion/GitVersion.Generated.cs:line 121
   at Nuke.Common.Tools.GitVersion.GitVersionAttribute.GetValue(MemberInfo member, Object instance) in /_/source/Nuke.Common/Tools/GitVersion/GitVersionAttribute.cs:line 47
   at Nuke.Common.ValueInjection.ValueInjectionAttributeBase.TryGetValue(MemberInfo member, Object instance) in /_/source/Nuke.Common/ValueInjection/ValueInjectionAttributeBase.cs:line [25]

I tried to upgrade GitVersion.Tool from 5.8.0 to 5.10.3, but still get the same behavior

Reproduction Steps

I must admit that I don't know how easy this is to reproduce, since I experience this in a Github repo with an action running a build with .Net 6.0.400 on ubuntu-latest. It seems like this happens in the intialization of the build before any of my own targets

Maybe its easier if you look at my build project to see how you can reproduce this?
https://github.com/ebjornset/DryGen/tree/main/build

Expected Behavior

[INF] > /home/runner/.dotnet/dotnet /home/runner/.nuget/packages/gitversion.tool/5.10.3/tools/net5.0/any/gitversion.dll /nocache injects "Build.GitVersion" ok.

https://github.com/ebjornset/DryGen/runs/8170096546?check_suite_focus=true

Actual Behavior

[INF] > /home/runner/.dotnet/dotnet /home/runner/.nuget/packages/gitversion.tool/5.10.3/tools/net5.0/any/gitversion.dll /nocache
Warning: Could not inject value for "Build.GitVersion"

Nuke 6.2.1 and GitVersion.Tool 5.10.3:
https://github.com/ebjornset/DryGen/actions/runs/2984614477
Nuke 6.2.1 and GitVersion.Tool 5.8.0:
https://github.com/ebjornset/DryGen/actions/runs/2984639947

Regression?

This worked ok in Nuke 6.0.3, both with GitVersion.Tool 5.8.0 and GitVersion.Tool 5.10.3

Nuke 6.0.3 and GitVersion.Tool 5.10.3:
https://github.com/ebjornset/DryGen/runs/8170046061?check_suite_focus=true
Nuke 6.0.3 and GitVersion.Tool 5.8.0:
https://github.com/ebjornset/DryGen/runs/8163473043?check_suite_focus=true

Known Workarounds

Continue to use Nuke 6.0.3

@ebjornset ebjornset changed the title Running build with Nuke 6.2.1 (and 6.1.2) in an Github action on ubuntu-latest fails Could not inject value for "Build.GitVersion" Running build with Nuke 6.2.1 (and 6.1.2) in an Github action on ubuntu-latest fails getting git version information: Could not inject value for "Build.GitVersion" Sep 3, 2022
@matkoch
Copy link
Member

matkoch commented Sep 3, 2022

You have a shallow clone of the repository.

Would also appreciate a star on the project 👍

@ebjornset
Copy link
Author

@matkoch , thanks for the quick reply.

I'm using attributes inheriting from Nuke's GitHubActionsAttribute to generate my Github actions, and noticed that when I upgraded to Nuke 6.2.1 my actions got modified by Nuke to use actions/checkout@v2. So I think the issue is caused by a behavioral change in actions/checkout between version 1 and 2. But how can I force Nuke 6.2.1 to use actions/checkout@1 or to add some extra parameters to force actions/checkout@v2 to not use a shallow clone?

@matkoch
Copy link
Member

matkoch commented Sep 3, 2022

It's always good to check out what I'm doing in the build script: https://github.com/nuke-build/nuke/blob/develop/build/Build.CI.GitHubActions.cs#L14

Yes, GitHub changed the behavior there... I'm also not a big fan of that.

@ebjornset
Copy link
Author

ebjornset commented Sep 3, 2022

Yepp, adding FetchDepth = 0 to all my Github action attributes made them work again after upgrading from Nuke 6.0.3 to 6.2.1 👍

@igiona
Copy link

igiona commented Feb 5, 2023

See here for the same solution for Bitbucket Pipelines: #944 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants