Cannot create and deploy a release using powershell for a project having the process "DEPLOY A RELEASE" in it

.image
Consider “X” is my project and , I want to create release for this project using powershell and using rest APIs. But If I use the above process (Deploy Release of another project) The invoke web request doesn’t work properly. showing error =>
"Invoke-WebRequest : The remote server returned an error: (400) Bad Request.
At line:53 char:6
+ $r = Invoke-WebRequest -Uri $OctopusURL/api/releases -Method Post -He …
**+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
** + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException**
** + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand** " Tried a lot but showing error.

I use this below powershell (Click URL) for creating release and deploy

If I have a simple process without the deploy a release process, it will work. But if I use this process (deploy release of another project) it doesn’t work and shows the above error.

Hi Yadukrishnan,

Thanks for getting in touch! I’ve given this script a test and reproduced this behavior both with Deploy a Release steps and standard package steps. However it works if you don’t have these steps (i.e. just a script step in my testing).

Since the Deploy a Release step exposes release versions of the ‘child projects’ in the same way as package steps expose packages and versions, I think all you’ll have to add to this POST to /api/releases is the package version for each package step. Does the following sample script get this going as expected?

You’d need to input the values of your Deploy a Release step and release version of the child project in this line:

"SelectedPackages":[{"StepName":"Deploy1","Version":"1.0.3"},

I hope this helps, and I look forward to hearing how you go!

Best regards,

Kenny

Hi, Thank you so much for your kind and immediate support, it works for me. :blush::blush:

Hi Yadukrishnan,

That’s great to hear it works for you! You’re very welcome, and please don’t hesitate to reach out if you have any further questions moving forward. :slight_smile:

Best regards,

Kenny

Hi, Is there any way to get the status (I mean Success, Progressing, or Failed) of a deployment to powershell ? I can’t find a proper API Key and Value for this. My Concern is here :
If the deployment is success then I need to proceed to next step in my script. If the deployment is progressing I need to wait until it become complete. If deployment is failed I need to get the failed status to my script.

Hi Yadukrishnan,

Thanks for following up! You can certainly track the deployment status, either for individual steps or the deployment as a whole. There are some built-in system variables that contain this information during a deployment, and you can reference them at the following link. :slight_smile:

https://octopus.com/docs/deployment-process/variables/system-variables#Systemvariables-DeploymentStatusTrackingdeploymentstatus

I hope this helps! Let me know how you go or if you have any further questions moving forward.

Best regards,

Kenny

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.