Uploading XL Deploy DAR package via PowerShell


Recently at my customer’s site, I started using XebiaLabs product called XL Deploy. It is a software solution that helps automating the deployment process. Many operations are exposed via a REST API. Uploading of packages is one of them and is done following the Multipart/form-data standard. In case you need to do so, via PowerShell, you may be surprised about the difficulty of something that appears to be a trivial task. As you may know, PowerShell doesn’t play well with Multipart/form-data requests. I will show you a cmdlet that I wrote that can be handy in accomplishing this task.

Welcome Send-Package cmdlet

Before showing you the actual cmdlet that will send a package to XL Deploy I need to mention that the core of this cmdlet is Invoke-MultipartFormDataUpload cmdlet about which I blogged earlier.

First of all two small helper cmdlets. As the file name needs to be specified in the URL, we need to encode it. This may be done with some simpler code for this particular case, however I will show you a cmdlet that I’m using also for other XL Deploy calls where this approach is necessary.

The other one will make sure that the URL passed in is formatted correctly for XL Deploy and that is a valid URL.

This cmdlets and the one I described in the previous post are required to be available for our new upload cmdlet. After having assured that they are available we can write a cmdlet I named Send-Package.

You can now invoke this cmdlet and pass the requested parameters. If the call succeeds you will get back the package id.

At example:

In case you do not want to provide credentials interactively, the following cmdlet may help you:

That’s all folks! I tested this scripts with XL Deploy 5.1.0 and 5.1.3 and had not encountered any issues. If any, do not hesitate to comment.

Happy deploying!

2 thoughts on “Uploading XL Deploy DAR package via PowerShell

  1. Wow, great blog Mario! Thanks for sharing in such a collaborative way. I hope you enjoy deploying with XL Deploy and we are all looking forward to more XLD tips in the future : )

Leave a Reply

Your email address will not be published. Required fields are marked *