0

I'm having an issue publishing to Github Packages from Jenkins using Cake.

The push task looks like this:

Task(nugetPushTask)
 .WithCriteria(() => isPublishBranch)
 .IsDependentOn(packTask)     
 .Does(() => {    

    foreach(var file in GetFiles(nugetFilesPath)) {
        DotNetNuGetPush(file, new DotNetNuGetPushSettings {
            ApiKey = "key_gdhsjgjhjkeykeykey",
            Source = "https://nuget.pkg.github.com/yourOrganizationOrAccount/index.json"
        });
    }

 }); 

Interestingly, I can successfully push the package with the following command:
dotnet nuget push nameofpackage.1.0.0.nupkg --source github --api-key key_gdhsjgjhjkeykeykey
using a shell prompt.

The error which I see in the build log for that step is:

An error occurred when executing task 'PublishGithub'.

System.Exception: Github Package Key Environment Variable is not set correctly.

at Submission#0.<>b__0_7(ICakeContext context)

at Cake.Core.CakeTaskBuilderExtensions.<>c__DisplayClass39_0.b__0(ICakeContext context) in C:\projects\cake\src\Cake.Core\CakeTaskBuilder.Execution.cs:line 81

at Cake.Core.CakeTask.Execute(ICakeContext context) in C:\projects\cake\src\Cake.Core\CakeTask.cs:line 119

at Cake.Core.DefaultExecutionStrategy.ExecuteAsync(CakeTask task, ICakeContext context) in C:\projects\cake\src\Cake.Core\DefaultExecutionStrategy.cs:line 69

at Cake.Core.CakeEngine.ExecuteTaskAsync(ICakeContext context, IExecutionStrategy strategy, Stopwatch stopWatch, CakeTask task, CakeReport report) in C:\projects\cake\src\Cake.Core\CakeEngine.cs:line 318

Can anyone advise how to get Cake to do what the CLI command is doing.

Thanks

onefootswill
  • 3,707
  • 6
  • 47
  • 101
  • 1
    So, what is the issue? – Nils Jan 12 '23 at 11:09
  • @Nils Sorry, I should have included the error message, which I write using Cake's Error method in OnError. – onefootswill Jan 12 '23 at 20:35
  • You can add `--settings_showprocesscommandline=true` to show the commandline that Cake will execute and then compare that to your working commandline. You could also add `--verbosity=diagnostic` to get a bit more information. – Nils Jan 13 '23 at 22:36
  • 1
    @Nils I have resolved my issue. It was some code in my cake script. Programmer error. Thanks for your help. This question is probably worth deleting, unless you'd like me to keep it here. Cheers. – onefootswill Jan 15 '23 at 21:58

0 Answers0