overwriteMode not working AzDo Server yaml

Answer: Check this post.

Hi,

I’m trying to use the overwriteMode flag when pushing a package. According to documentation here it should be --overwrite-mode=<value>.

Version 2019.13.7 on-prem

==============================================================================
Task         : Push Package(s) to Octopus
Description  : Push your NuGet or Zip package to your Octopus Deploy Server
Version      : 3.0.431
Author       : Octopus Deploy
Help         : Version: 4.1.431. [More Information](https://g.octopushq.com/TFS-VSTS)
==============================================================================

and here’s the task

- task: OctopusPush@3
  displayName: 'Octopus push'
  inputs:
    octoConnectedServiceName: '****'
    package: '$(Build.StagingDirectory)/$(octopusPackageId).$(Build.BuildNumber).nupkg'
    # Should work according to https://octopus.com/docs/octopus-rest-api/octopus-cli/push
    #AdditionalArguments: '--overwrite-mode=OverwriteExisting'
    overwriteMode: 'OverwriteExisting'

None of the above works, Any idea?

Also - how to I configure release to be deployed directly from yaml task?

Update

D:\TfsAgent04\_work\1213\s>dotnet "D:\TfsAgent04\_work\_tool\Octo\7.3.2\x64\/octo.dll" version 
7.3.2
[command]C:\Windows\system32\cmd.exe /D /S /C "D:\TfsAgent04\_work\_tool\octo\7.3.2\x64\octo.cmd push "--server=https://octopus/" "--apiKey=***" "--package=D:/TfsAgent04/_work/1213/a/<nupkg>.nupkg" "--overwrite-mode=FailIfExists""

D:\TfsAgent04\_work\1213\s>dotnet "D:\TfsAgent04\_work\_tool\Octo\7.3.2\x64\/octo.dll" push "--server=https://octopus/" "--apiKey=***" "--package=D:/TfsAgent04/_work/1213/a/<nupkg>.nupkg" "--overwrite-mode=FailIfExists" 
Octopus Deploy Command Line Tool, version 7.3.2

Detected automation environment: "AzureDevOps"
Space name unspecified, process will run in the default space context
Handshaking with Octopus Server: https://octopus/
Handshake successful. Octopus version: 2019.13.7; API version: 3.0.0
Authenticated as: tfsservice 
Pushing package: D:\TfsAgent04\_work\1213\a\<package>.nupkg...
Requesting signature for delta compression from the server for upload of a package with id '<id>' and version '1.0.0-alpha.0.41'
Calculating delta
The delta file (136 833 bytes) is 0,28 % the size of the orginal file (49 133 004 bytes), uploading...
There was a problem with your request.

 - A package with the same ID and version already exists. To proceed anyway, specify an overwriteMode of OverwriteExisting or IgnoreIfExists.
- task: OctopusPush@4
  displayName: 'Octopus push'
  inputs:
    octoConnectedServiceName: 'Octopus'
    package: '$(Build.StagingDirectory)/$(octopusPackageId).$(Build.BuildNumber).nupkg'
    overwriteMode: 'OverwriteExisting'

Still not working

Hi Joakim,

Thanks for getting in touch! I’m sorry to hear you’re hitting this unexpected issue. I’ve seen this exact error occur in the past which was resolved by upgrading the version of the Octopus CLI. Since the snippet above reports an older version, upgrading this would be the first thing I’d try. The following doc page provides some information on using your own version if required.

A few options to deploy a newly created release automatically:

  • add on the argument --deployTo=<Environment> to an existing create-release command;
  • add a subsequent step after the release is created to use the deploy-release command;
  • Configure the first environment in the relevant project’s lifecycle to automatically deploy

I hope this helps! let me know how you go or if you have any questions or concerns moving forward. :slight_smile:

Best regards,

Kenny

Thanks I’ve created a ticket for our infra team to upgrade CLI version. Hopefully it gets done soon and I can test it out.

Thanks again for quick answer

Hi Joakim,

You’re very welcome. I hope that gets you up and running, and please don’t hesitate to reach out if you have any questions or concerns moving forward.

Best regards,

Kenny

Tried the release arguments and get this error

##[error]Cannot validate argument on parameter 'Arguments'. The argument "create-release --project="<project>" --releaseNumber="1.0.0-alpha.0.46" --channel="Sweden" --server=https://octopus/ --apiKey=*** --enableServiceMessages  --releaseNotesFile="D:\..\file.md" '--package <packageid>:1.0.0-alpha.0.46'
'--waitForDeployment false'
'--deployTo Environments-193'" does not match the "^[^\r\n]*$" pattern. Supply an argument that matches "^[^\r\n]*$" and try the command again.

My yaml

- task: OctopusCreateRelease@2
  displayName: 'Octopus release'
  inputs:
    octoConnectedServiceName: 'Octopus'
    projectName: '$(octopusProject)'
    releaseNumber: '$(Build.BuildNumber)'
    channel: 'Sweden'
    AdditionalArguments: |
        '--package $(octopusPackageId):$(Build.BuildNumber)'
        '--waitForDeployment false'
        '--deployTo Environments-<id>'

Update Added waitForDeployment: false and dito with deployTo and the task executes correctly but it isn’t deployed to designated environment.

Update 2 Upgraded to @3 and use the OctopusInstaller@4 and then I get this error

Unrecognized command arguments: '--packageVersion, 1.0.0-alpha.0.52'
This error is most likely occurring while executing octo as part of an automated build process. The following doc is recommended to get some tips on how to troubleshoot this: https://g.octopushq.com/OctoexeTroubleshooting
Exit code: -1

Switching to deployTo: Environments-<id> style the task executes but the release isn’t deployed.

Perhaps I need to update OctopusCreateRelease to a newer. I’ll try that as soon as CLI version has been updated. Where can I find documentation on what arguments are made avilable directly under inputs vs those that I need to pass as AdditionalArguments?

Thanks

Hi Joakim,

Thanks for keeping in touch! You might have some luck updating the CLI (and I’d recommend it regardless), but perhaps you could also try splitting this --deployto argument into a separate Deploy Release step? I hope one of those options gets you going, and I look forward to hearing back!

Best regards,

Kenny

Hi and thanks for the help. Couldn’t get the key: value syntax to work however additionalArguments does.

Working setup to deploy newly created release with the created package


- task: OctopusPush@4
  displayName: 'Octopus push'
  inputs:
    octoConnectedServiceName: 'Octopus'
    package: '$(Build.StagingDirectory)/$(octopusPackageId).$(Build.BuildNumber).nupkg'
    additionalArguments: --overwrite-mode OverwriteExisting

# https://octopus.com/docs/octopus-rest-api/octopus-cli/create-release
- task: OctopusCreateRelease@4
  displayName: 'Octopus release'
  inputs:
    octoConnectedServiceName: 'Octopus'
    projectName: '$(octopusProject)'
    releaseNumber: '$(Build.BuildNumber)'
    channel: 'Sweden'
    additionalArguments: "--deployTo Environments-<id> --packageVersion $(Build.BuildNumber)"

It seem that --waitForDeployment false is default behavior.

Thanks for you help.

Hi @joakim.carselind,

Thanks for following up! I’m sorry for the confusion here. I checked in our test setup and for Ignore If Exists you get the following in the YAML:

Replace: IgnoreIfExists

So that doesn’t align with the Octopus CLI parameters. If you pick Overwrite Existing then the value of Replace is true . Fail if exists is the default so no value appears. Some of this is to do with the TypeScript markup requirements of ADO, mixed with us having to do things for backward compatibility.

The name is actually derived from here for the Push step’s YAML. The possible values are listed just below.

I hope this helps, and please don’t hesitate to reach out if you have any questions or concerns moving forward!

Best regards,

Kenny