Search code examples
artifactory

Artifactory "System cannot find the path" when pushing to repo


I set up a NuGet repo in Artifactory using the free tier account. I followed the "Quick Setup" instructions to register the API key, add the source, and push my first package. That all worked easily when I was logged into my build machine as myself.

Next, I decided I wanted to integrate this into my GitLab pipeline, such that I can push my package as part of the deploy stage. I used the identical command, yet I get an error that "System cannot find the path specified". I am almost certain the issue is related to using the Artifactory source as I can swap the source URL for a local repo path and the command succeeds.

This is the command I am running:

nuget push MyApp.1.0.0.nupkg -Source https://myco.jfrog.io/artifactory/api/nuget/my-repo -ApiKey user:pass

The result when running my GitLab pipeline job is:

Pushing MyApp.1.0.0.nupkg to 'https://myco.jfrog.io/artifactory/api/nuget/my-repo/'...
error: The system cannot find the path specified.

What machine variables or state would prevent pushing to Artifactory at the machine level? Or is it some other issue entirely?


Solution

  • I suspect this to be a conflict occurred due to the usage of API Key arguments alongside username:password (encrypted). Even if we are not configuring the API key for the source, NuGet client has the ability to compare the configuration file for the existing credentials for the source URL and fetch it automatically.

    I have shared the flow of deployment when API key is not set.

    $ nuget push serilog.2.9.2-dev-01154.nupkg -Source http://nuget-test-artifactory.com/artifactory/api/nuget/test-nuget/ WARNING: No API Key was provided and no API Key could be found for 'http://nuget-test-artifactory.com/artifactory/api/nuget/test-nuget/'. To save an API Key for a source use the 'setApiKey' command. Pushing serilog.2.9.2-dev-01154.nupkg to 'http://nuget-test-artifactory.com/artifactory/api/nuget/test-nuget/'... PUT http://nuget-test-artifactory.com/artifactory/api/nuget/test-nuget/ MSBuild auto-detection: using msbuild version '15.0' from '/Library/Frameworks/Mono.framework/Versions/6.4.0/lib/mono/msbuild/15.0/bin'. Using credentials from config. UserName: admin Created http://nuget-test-artifactory.com/artifactory/api/nuget/test-nuget/ 6160ms Your package was pushed.

    So, if you have already set the Source with the username:password via the following command execution,

    nuget sources Add -Name Artifactory -Source http://ARTIFACTORY_HOSTNAME/artifactory/api/nuget/test-nuget -username admin -password <ENCRYPTED_PASSWORD>
    

    consider executing the below command to perform the deployment (custom layout),

    nuget push <PACKAGE> -Source http://ARTIFACTORY_HOSTNAME/artifactory/api/nuget/test-nuget/<PATH_TO_FOLDER>
    

    If you would like to perform the deployment with the default layout, then executing just the following command should suffice.

    nuget push <PACKAGE_NAME> -Source Artifactory