Publishing to Github Packages from Jenkins Using Cake

119 views Asked by At

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

0

There are 0 answers