NuKeeper icon indicating copy to clipboard operation
NuKeeper copied to clipboard

NuKeeper reports success even if Git operation fails

Open ianjirka opened this issue 4 years ago • 14 comments

🐛 Bug Report

If NuKeeper cannot perform a git operation and fails, it still reports success via errorlevel = 0. This will impact any automation system that leverages NuKeeper (in my case, Azure DevOps)

Expected behavior

If NuKeeper fails it reports as a failure so automation (such as DevOps) can correctly notify that a failure occurred.

Reproduction steps

Configure project with NuKeeper in any environment that doesn't provide it access to push. Simply denying branch creation rights should be sufficient, or putting into an ADO pipeline without token access.

Updates failed LibGit2SharpException : request failed with status code: 403 at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) at LibGit2Sharp.Core.Proxy.git_remote_push(RemoteHandle remote, IEnumerable1 refSpecs, GitPushOptions opts) at LibGit2Sharp.Network.Push(Remote remote, IEnumerable1 pushRefSpecs, PushOptions pushOptions) at LibGit2Sharp.Network.Push(IEnumerable1 branches, PushOptions pushOptions) at NuKeeper.Git.LibGit2SharpDriver.<>c__DisplayClass17_0.<Push>b__0() in d:\a\r1\a\drop\NuKeeper.Git\LibGit2SharpDriver.cs:line 189 at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location where exception was thrown --- at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot) --- End of stack trace from previous location where exception was thrown --- at NuKeeper.Engine.Packages.PackageUpdater.MakeUpdatePullRequests(IGitDriver git, RepositoryData repository, NuGetSources sources, SettingsContainer settings, IReadOnlyCollection1 updates) in d:\a\r1\a\drop\NuKeeper\Engine\Packages\PackageUpdater.cs:line 85 at NuKeeper.Engine.Packages.PackageUpdater.MakeUpdatePullRequests(IGitDriver git, RepositoryData repository, IReadOnlyCollection`1 updates, NuGetSources sources, SettingsContainer settings) in d:\a\r1\a\drop\NuKeeper\Engine\Packages\PackageUpdater.cs:line 46

Configuration

nukeeper 0.26.0 x64

Platform if applicable:

  • [ ] :hammer_and_wrench: NuKeeper CLI
  • [ ] :sparkles: GitHub
  • [X] :robot: AzureDevops
  • [ ] :checkered_flag: Bitbucket
  • [ ] :earth_americas: Gitlab
  • [ ] :tv: Gitea
  • [ ] :whale: Docker

ianjirka avatar Mar 01 '20 22:03 ianjirka

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 30 '20 23:05 stale[bot]

Should still look into this?

AnthonySteele avatar Jun 01 '20 09:06 AnthonySteele

It will also report success if NuGet.exe throws an exit code other than 0 which is not desirable behaviour as running nukeeper on a CI agent will report a success, even though packages have not been updated properly because of an error.

Definitely should report a proper exit code if any part of the process fails. @AnthonySteele

scp-mb avatar Jun 11 '20 15:06 scp-mb

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 09 '20 16:09 stale[bot]

Has any changes been made for this so far? If not it's still relevant.

scp-mb avatar Sep 14 '20 09:09 scp-mb

I am experiencing the same behavior when package cannot be updated for some reason Example

Updating 'Microsoft.Extensions.Configuration.Abstractions' to 3.1.8 in 8 projects
...
/tmp/NuKeeper/repo-c59bd8d6b834403694776ed8bef12eac/source/MySampleProject/MySampleProject.csproj : error NU1605: Detected package downgrade: Microsoft.Extensions.Configuration.Abstractions from 3.1.8 to 3.1.6. Reference the package directly from the project to select a different version. 
...
Command dotnet failed with exit code: 1

But nukeeper exits with code 0:

$ echo $?
0

This is really important in CI scenarios, where exit code indicates whether process succeeded or failed.

wojciechrak avatar Oct 08 '20 12:10 wojciechrak

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jan 06 '21 16:01 stale[bot]

Still relevant AFAIK

scp-mb avatar Jan 07 '21 10:01 scp-mb

Still very relevant. Last week this hides several errors which I recognized yesterday.

MartinDemberger avatar Mar 24 '21 16:03 MartinDemberger

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 22 '21 21:06 stale[bot]

In my CI, I run NuKeeper from a PowerShell task and parse the results. If no packages were updated, I throw an error. Maybe this can help you. Now I need to find out why NuKeeper doesn't always find the newest package from my feed even though it is in there.

- powershell: |
    git config --global user.name "Matt Edwards"
    git config --global user.email "[email protected]"
    $test = nukeeper update $(build.sourcesDirectory) --age 0 -v d
    $match = $test -Match "Found no package updates"
    echo $test
    if ( $match ) { Write-Error "Error - Found no package updates" } else { Write-Output "Success - Updated project packages" }
  failOnStderr: true
  displayName: 'NuKeeper'

ghost avatar Jul 08 '21 12:07 ghost

This is also an issue for me.

ceejeeb avatar Aug 16 '21 06:08 ceejeeb

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 15 '21 19:12 stale[bot]

Still relevant

scp-mb avatar Dec 15 '21 21:12 scp-mb