NuKeeperDotNet / NuKeeper

Automagically update nuget packages in .NET projects
Apache License 2.0
540 stars 129 forks source link

Azure DevOps running "org" command fails to create the PR, throws NullReferenceException #1110

Open spr0ut opened 3 years ago

spr0ut commented 3 years ago

🐛 Bug Report

When running nukeeper with the "org" command in Azure DevOps (hosted agent), the branch(es) are created and pushed, but NuKeeper fails to create the PR and throws a NullReferenceException.

Git commit with message '📦 Automatic update of CsvHelper to 27.0.2'
Git push to nukeeper_push/nukeeper-update-CsvHelper-to-27.0.2
GetGitRepositories: Requesting version-test/_apis/git/repositories?api-version=4.1
GetPullRequests: Requesting version-test/_apis/git/repositories/1eb94f14-1adb-45e0-ada9-1ac873db1df3/pullrequests?searchCriteria.sourceRefName=refs%2fheads%2fnukeeper-update-CsvHelper-to-27.0.2&searchCriteria.targetRefName=refs%2fheads%2fmain&api-version=4.1
Updates failed NullReferenceException : Object reference not set to an instance of an object.
   at NuKeeper.Engine.Packages.PackageUpdater.MakeUpdatePullRequests(IGitDriver git, RepositoryData repository, NuGetSources sources, SettingsContainer settings, IReadOnlyCollection`1 updates) in D:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper\Engine\Packages\PackageUpdater.cs:line 140
   at NuKeeper.Engine.Packages.PackageUpdater.MakeUpdatePullRequests(IGitDriver git, RepositoryData repository, IReadOnlyCollection`1 updates, NuGetSources sources, SettingsContainer settings) in D:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper\Engine\Packages\PackageUpdater.cs:line 65
Attempted 3 updates and did 0

Expected behavior

PR's are created.

Reproduction steps

Create sample repo(s) with minimal cs proj file as contents. Create YAML pipeline - run nukeeper install and org with PAT token

steps:
- script: dotnet tool install nukeeper --global
- script: |
    git config --global user.email user@domain.com
    git config --global user.name NuKeeper
- script: nukeeper org version-test $(PAT) --api https://dev.azure.com/ORG_NAME -v D

Observe errror.

Configuration

Version: 0.34.0

Platform if applicable:

stale[bot] commented 3 years ago

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.

spr0ut commented 3 years ago

bump

adlanelm commented 2 years ago

This fails due to settings.SourceControlServerSettings.Repository value being null. Looks like the value will be set only when executing a command that operates on a single repo.

Depending on where the authors want to go with the design of this I see a couple of alternatives how this can be solved.

  1. Run settings.SourceControlServerSettings.Repository = repository while iterating through discovered repos either in CollaborationEngine.Run() or GitRepositoryEngine.Run()
  2. Remove Repository from SourceControlServerSettings and instead always pass around RepositorySettings separately.

What suits future plans best? Any other ideas?

CumpsD commented 2 years ago

Same with Github it seems.

Checking if PR exists onto 'https://api.github.com/ xxx/xxx: main <= nukeeper-update-14-packages-DC1C0BF46CE1C6EC900BE0E1A13D0037
Failed on repo xxx NullReferenceException : Object reference not set to an instance of an object.
raunaknarooka commented 2 years ago

I have the same issue while running nukeeper org in github actions.

Failed on repo xx NullReferenceException : Object reference not set to an instance of an object.
   at NuKeeper.Engine.Packages.PackageUpdater.MakeUpdatePullRequests(IGitDriver git, RepositoryData repository, NuGetSources sources, SettingsContainer settings, IReadOnlyCollection`1 updates) in D:\a\r1\a\_NuKeeper PR Build\drop\NuKeeper\Engine\Packages\PackageUpdater.cs:line 157