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

Nuget source credentials management #1382

Closed
Vilmir opened this issue Jan 13, 2016 · 12 comments
Closed

Nuget source credentials management #1382

Vilmir opened this issue Jan 13, 2016 · 12 comments

Comments

@Vilmir
Copy link

@Vilmir Vilmir commented Jan 13, 2016

Hello,
We are preparing the introduction of Paket for managing package references in our company for our main product codebase.
The packages for this codebase are stored in an Artifactory repository with no anonymous access.
Developers need to use their LDAP company credentials to access it, the build agents are using a build account.
A developer's password changes every 3 months, the build account password never changes.

We would like to use the command paket.exe config add-credentials to solve this problem.
It works fine to restore packages once the credentials are stored.
But when using this solution, we also need to catch up the moment where the stored credentials need to change properly.
We handle calling paket.bootstrapper.exe and paket.exe from a bootstrap.bat file in the root of our codebase. I wanted to programmatically detect when paket was failing to restore packages because of credentials.

Unfortunately, neither paket.bootstrapper.exe or paket.exe are returning a proper exit code different than 0 when there is a critical error:

  • paket.bootstrapper.exe is ordered to force download from Nuget, from a Nuget feed that does not exist, it returns exit code 0 (I tried to simulate a situation where the dev cannot access internet)
  • paket.exe is ordered to restore packages and the nuget source credentials are incorrect, it returns 0

The simple batch script I wrote to test that, meant to be executed from the root folder of the codebase:

@ECHO off

echo Downloading latest paket.exe with paket.boostrapper.exe

call "%~dp0\.paket\paket.bootstrapper.exe" --force-nuget --nuget-source=https://artifacts.sonova.com/artifactory/api/nuget/chinook-production

echo Exit Code for paket.bootstrapper.exe is %errorlevel%

if errorlevel 1 (

    if exist "%~dp0\.paket\paket.exe" (

        echo paket.bootstrapper.exe failed, but current paket.exe is present and can be used

    ) else (
        echo paket.bootstrapper.exe failed, and there is no existing paket.exe file.

        echo Package restoration process cannot continue

        pause

        exit /b 1
    )
)

echo.

echo Restoring packages with paket.exe

call "%~dp0\.paket\paket.exe" restore

echo Exit Code for paket.exe restore is %errorlevel%

if errorlevel 1 (
   echo paket.exe failed to restore packages

   exit /b %errorlevel%
)

pause

@ECHO on
@forki
Copy link
Member

@forki forki commented Jan 13, 2016

exitcode is always set when an exception is hit. what is the reported error message?

@Vilmir
Copy link
Author

@Vilmir Vilmir commented Jan 13, 2016

Here is the output:

C:\SVN\Chinook2>Bootstrap.bat
Downloading latest paket.exe with paket.boostrapper.exe
No version specified. Downloading latest stable.
The remote server returned an error: (401) Unauthorized. (Nuget)
Exit Code for paket.bootstrapper.exe is 0

Restoring packages with paket.exe
Paket version 2.42.4.0
credentials for https://artifacts.sonova.com/artifactory/api/nuget/chinook-produ
ction source are invalid
credentials for https://artifacts.sonova.com/artifactory/api/nuget/chinook-produ
ction source are invalid
0 seconds - ready.
Exit Code for paket.exe restore is 0
Press any key to continue . . .
@forki
Copy link
Member

@forki forki commented Jan 13, 2016

regarding bootstrapper: if the paket.exe is already there we don't change exit code, because usually it's no issue to just proceed.

@forki
Copy link
Member

@forki forki commented Jan 13, 2016

th other one is strange. can I reproduce?

@Vilmir
Copy link
Author

@Vilmir Vilmir commented Jan 13, 2016

Thanks for the explanation. If I delete paket.exe, then the bootstrapper returns as expected an errorlevel equal to 1

For the paket.exe, I think you can reproduce by using my batchfile code within a simple folder with 1 project. What matters is that either the credentials you put in the config are wrong, or the source does not exist, with a typo in the URL per example.

@forki
Copy link
Member

@forki forki commented Jan 13, 2016

I think I need your paket.dependencies and paket.lock. Sforkmann @ Gmail

@Vilmir
Copy link
Author

@Vilmir Vilmir commented Jan 13, 2016

Sent!

@isaacabraham
Copy link
Contributor

@isaacabraham isaacabraham commented Jan 13, 2016

I'm wondering if it's worth looking at using Paket programmatically through the NuGet package in an F# script - might you be able to better reason about errors etc. rather than through a batch file?

@Vilmir
Copy link
Author

@Vilmir Vilmir commented Jan 13, 2016

That's what I thought too.
How stable is the current Paket API regarding the restore command? We would like to benefit from new Paket versions without having to update this bootstrap code too often :)

@forki forki closed this in f5f7fdc Jan 13, 2016
@forki
Copy link
Member

@forki forki commented Jan 13, 2016

credentials are now throwing properly.

@Vilmir
Copy link
Author

@Vilmir Vilmir commented Jan 14, 2016

Thanks Steffen, indeed now paket.exe returns 1 when credentials are outdated!

@Treit
Copy link

@Treit Treit commented Mar 15, 2017

How does one delete stored credentials? I was trying to troubleshoot an issue where paket cannot connect to one of our package feeds and it is now stuck failing (every time) with Credentials from authentication store for <myUrl> are invalid...and now I have no idea how to get rid of the stored credentials.

Edit:
Nevermind, found it: del /q %appdata%\paket\*

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

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.