My organization has had the need to tighten the security in regards what’s available in the intranet, in that regard I’ve had to setup a more secure nuget server.
We’ve been using your TeamCity Plugin for a while to create nuget packages and it is our preferred way of creating packages that are going to our Octopus Deploy nuget feed (which is hosted by ProGet).
In the setup of Octopack you have a field called ‘Publish API key’, which is a password field. Normally it would be fine, however we’d like to use a parameter to contain the apikey. The parameter itself is protected as a password in TeamCity, but we can’t use a parameter in a password textbox.
Is it possible to a argument field for Octopus publishing?
So we can add f.ex. the argument -apikey to the Octopack build?
I tried to add
/p:OctopusPublishPackageToHttp=%someTeamCity nuget apikey%
and still have the octopack enabled
[Exec] EXEC No API Key was provided and no API Key could be found for ‘http://packages.helsenord.no:8585/nuget/IntegrationOctopack/’. To save an API Key for a source use the ‘setApiKey’ command.
The MSBuild runner isn’t a fan of command line parameters …
I the following output from MSBuild
“[MSBuild output] Start MSBuild…
[15:16:25] [MSBuild output] ‘C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin\MSBuild.exe’ '”@C:\TeamCityBuildAgent\work\5bedbb1d25d295aa\RemoteLinqWcf\RemoteLinqWcf.csproj.teamcity.msbuild.tcargs" C:\TeamCityBuildAgent\work\5bedbb1d25d295aa\RemoteLinqWcf\RemoteLinqWcf.csproj.teamcity’
[15:16:25] [MSBuild output] working dir = ‘C:\TeamCityBuildAgent\work\5bedbb1d25d295aa’
[15:16:25] [MSBuild output] Microsoft ® Build Engine version 15.1.1012.6693
[15:16:25] [MSBuild output] Copyright © Microsoft Corporation. All rights reserved.
[15:16:25] [MSBuild output]
[15:16:25] [MSBuild output] MSBUILD : error MSB1008: Only one project can be specified.
[15:16:25] [MSBuild output] Switch: C:\TeamCityBuildAgent\work\5bedbb1d25d295aa\RemoteLinqWcf\RemoteLinqWcf.csproj.teamcity
[15:16:25] [MSBuild output]
[15:16:25] [MSBuild output] For switch syntax, type “MSBuild /help”
I rarely use the MSBuild runner and I were missing a parameter for type of build I was compiling.
Anyway, I notice the parameter /p:OctoPackPublishApiKey is ignored when I run the build. The -apikey parameter should have been added to the nuget.exe command during publishing.
RemoteLinq_Octopack_1.0.30.log (47 KB)
Hi Harald, thanks for reaching out.
I think the easiest way to achieve what you are looking for is to bypass the Octopack TeamCity plugin altogether by leaving the Run OctoPack checkbox unchecked.
As you can see in the plugin source code at https://github.com/OctopusDeploy/Octopus-TeamCity/blob/master/octopus-agent/src/main/java/octopus/teamcity/agent/OctopusBuildListener.java#L49 if the checkbox is not enabled, no parameters will be added to the runner.
So leaving this checkbox blank should prevent MSBuild command line parameters (like /p:OctoPackPublishApiKey) from being overwritten by blank fields.
You can then manually add the command line parameters that normally would have been added by the OctoPack TeamCity plugin:
/p:RunOctoPack=true /p:OctoPackPackageVersion=<version> /p:OctoPackAppendToPackageId=<append> /p:OctoPackPublishPackageToHttp=<package> /p:OctoPackPublishApiKey=<apikey>