Failed package step doesn't fail

operations

(Jeff Mounce) #1

When we return Exit 1 or Throw in the PostDeploy.ps1 script, the log shows exit code of 0x1 but the Octopus step doesn’t fail. What gives?

176 additional lines not shown
June 13th 2018 14:18:49Info
Info: Updating file (AdjudicationMatrix-API\bin\STORM.Platform.pdb).
June 13th 2018 14:18:49Info
Info: Updating file (AdjudicationMatrix-API\bin\WAFbizComponents.dll).
June 13th 2018 14:18:49Info
Info: Updating file (AdjudicationMatrix-API\bin\WAFdbComponents.dll).
June 13th 2018 14:18:49Info
Info: Updating file (AdjudicationMatrix-API\bin\WAFMetadata.dll).
June 13th 2018 14:18:49Info
Info: Updating file (AdjudicationMatrix-API\bin\WAFwebComponents.dll).
June 13th 2018 14:18:49Info
Info: Updating file (AdjudicationMatrix-API\bin\Webhooks.Common.dll).
June 13th 2018 14:18:49Info
Info: Updating file (AdjudicationMatrix-API\bin\Webhooks.Common.pdb).
June 13th 2018 14:18:49Info
Info: Updating file (AdjudicationMatrix-API\bin\Workflow.Platform.dll).
June 13th 2018 14:18:49Info
Info: Updating file (AdjudicationMatrix-API\bin\Workflow.Platform.pdb).
June 13th 2018 14:18:49Info
Info: Deleting file (AdjudicationMatrix-API\release-notes.json).
June 13th 2018 14:18:50Info
Warning: An error was encountered when processing operation ‘Delete File’ on ‘release-notes.json’.
June 13th 2018 14:18:50Info
Retrying operation ‘Delete’ on object filePath (AdjudicationMatrix-API\release-notes.json). Attempt 1 of 5.
June 13th 2018 14:18:51Info
Warning: An error was encountered when processing operation ‘Delete File’ on ‘release-notes.json’.
June 13th 2018 14:18:51Info
Retrying operation ‘Delete’ on object filePath (AdjudicationMatrix-API\release-notes.json). Attempt 2 of 5.
June 13th 2018 14:18:53Info
Warning: An error was encountered when processing operation ‘Delete File’ on ‘release-notes.json’.
June 13th 2018 14:18:53Info
Retrying operation ‘Delete’ on object filePath (AdjudicationMatrix-API\release-notes.json). Attempt 3 of 5.
June 13th 2018 14:18:55Info
Warning: An error was encountered when processing operation ‘Delete File’ on ‘release-notes.json’.
June 13th 2018 14:18:55Info
Retrying operation ‘Delete’ on object filePath (AdjudicationMatrix-API\release-notes.json). Attempt 4 of 5.
June 13th 2018 14:18:55Info
Warning: An error was encountered when processing operation ‘Delete File’ on ‘release-notes.json’.
June 13th 2018 14:18:55Info
Retrying operation ‘Delete’ on object filePath (AdjudicationMatrix-API\release-notes.json). Attempt 5 of 5.
June 13th 2018 14:18:55Error
Error Code: ERROR_FILE_IN_USE
June 13th 2018 14:18:55Error
More Information: Web Deploy cannot modify the file ‘release-notes.json’ on the destination because it is locked by an external process. In order to allow the publish operation to succeed, you may need to either restart your application to release the lock, or use the AppOffline rule handler for .Net applications on your next publish attempt. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_FILE_IN_USE.
June 13th 2018 14:18:55Error
Error: The process cannot access ‘C:\inetpub\wwwroot\AdjudicationMatrix-API\release-notes.json’ because it is being used by another process.
June 13th 2018 14:18:55Error
Error count: 1.
6 additional lines not shown
June 13th 2018 14:18:55Info
Info: True v2.0.50727 C:\Windows\assembly\GAC_MSIL\Microsoft.Web.Administrat…
June 13th 2018 14:18:55Info
Info:
June 13th 2018 14:18:55Info
Info: Copying web.config from ‘C:\Octopus\Applications\beta\amapi-beta\11.11.404\content\web.config’ to ‘C:\inetpub\wwwroot\AdjudicationMatrix-API’…
June 13th 2018 14:18:55Info
Info:
June 13th 2018 14:18:55Info
Info: Copying version file from ‘C:\Octopus\Applications\beta\amapi-beta\11.11.404\content\version.txt’ to ‘C:\inetpub\wwwroot\AdjudicationMatrix-API’…
June 13th 2018 14:18:55Info
Info:
June 13th 2018 14:18:55Info
Info: Copying release notes from ‘C:\Octopus\Applications\beta\amapi-beta\11.11.404\content\release-notes.json’ to ‘C:\inetpub\wwwroot\AdjudicationMatrix-API’…
June 13th 2018 14:18:55Info
Info:
June 13th 2018 14:18:55Info
Warning: The process cannot access the file
June 13th 2018 14:18:55Info
Warning: ‘C:\inetpub\wwwroot\AdjudicationMatrix-API\release-notes.json’ because it is
June 13th 2018 14:18:55Info
being used by another process.
June 13th 2018 14:18:55Info
At C:\Octopus\Applications\beta\amapi-beta\11.11.404\AfterUnpack.ps1:89 char:7
June 13th 2018 14:18:55Info

  •   Throw $_.Exception.Message 
    

June 13th 2018 14:18:55Info

  •   ~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    

June 13th 2018 14:18:55Info
+ CategoryInfo : OperationStopped: (The process can…nother proc
June 13th 2018 14:18:55Info
ess.:String) [], RuntimeException
June 13th 2018 14:18:55Info
+ FullyQualifiedErrorId : The process cannot access the file ‘C:\inetpub\w
June 13th 2018 14:18:55Info
wwroot\AdjudicationMatrix-API\release-notes.json’ because it is being used
June 13th 2018 14:18:55Info
by another process.
June 13th 2018 14:18:55Info

June 13th 2018 14:18:55Error
Error: The process ‘C:\Windows\system32\cmd.exe’ (command line ‘’) exited with code ‘0x1’.
June 13th 2018 14:18:55Error
Error count: 1.
June 13th 2018 14:18:55Info
Error during ‘-postSync’.
June 13th 2018 14:18:55Verbose
Adding journal entry:
June 13th 2018 14:18:55Verbose

June 13th 2018 14:18:55Verbose
Process C:\Windows\system32\WindowsPowershell\v1.0\PowerShell.exe in C:\Octopus\Work\20180613211839-108794-335 exited with code 0
June 13th 2018 14:18:55Verbose
Updating manifest with output variables
June 13th 2018 14:18:55Verbose
Updating manifest with action evaluated variables
June 13th 2018 14:18:55Verbose
Planning retention policy
June 13th 2018 14:18:55Verbose
Successfully finished Deploy Application on hostname


(Lawrence Wilson) #3

Hi Jeff,
Thanks for getting in touch! I’m sorry to hear you are seeing a deployment continue irrespective of if the post-deployment step fails.

One potential option here could be to include $ErrorActionPreference = "Stop" at the beginning of your post-deployment step. By default, PowerShell’s error action preference is to Continue. In this case, when your script encounters non-terminating errors such as file not found, or permission problems it will tell you about them but your script will continue on.

I look forward to hearing if this suggestion works for you.

Kind regards,
Lawrence.


(Jeff Mounce) #4

We already do that.
Any unobvious suggestions?

Did you look at the log above?
Can you tell me why Octo returns 0 when the script obviously returns 1?


(Jeff Mounce) #5

Anyone there???


(Lawrence Wilson) #6

Hi Jeff,
Thanks for keeping in touch and letting us know you already set your error action preference to stop. I’m sorry for the long delay in getting back to you here. I have successfully reproduced the same behaviour you are seeing on my end. If I call a batch script from within an Octopus step that returns exit 0x1, the step proceeds without error. If I then run the same batch script with exit 1, this will fail as expected.

I will dig into this further on our end and I will update you further when I have more information here.

I look forward to getting in contact with you shortly.

Kind regards,
Lawrence