Custom script hook on Release Creation

timbomay's Avatar

timbomay

17 Jul, 2017 08:44 AM

Hi guys,

Is there a way that I can run a custom script when a release gets created?

Our scenario is that for years we have used MSI's with environmental transform to deploy our internal corporate products, and having recently started to use OD, we have decided to continue using MSI artefacts to do our setup (packaged and deployed via NuGet of course), then run locally using msiexec.exe.
We've also started to use multi-tenancy to support side-by-side deployments of identical product versionss that serve different teams, and this pattern seems to work pretty well so far.

One problem I've come accross though is the need to generate new 'Product Code' / per tenant / per release, which I can't seem to find a solution for.
We define an 'Upgrade Code' per tenant as a 'project variable template', which works as this doesn't change from release to release, however I need to generate a new 'Product Code' for each tenant per release version. I had hoped I might achieve this through a Release Creation script hook which could lookup each tenant, then generate a new GUID code for each, or some other way to do define a variable per release (as opposed to per deployment).

Any ideas?

  1. Support Staff 1 Posted by Nick Josevski on 18 Jul, 2017 12:14 AM

    Nick Josevski's Avatar

    Hello,

    Thanks for getting in touch. It sounds like the Subscription feature via Configuration will let you achieve your objective of tapping into and acting on when a Release is created.

    Subscriptions allow you to subscribe to events that are happening within Octopus, so you can be notified when events have occurred and react accordingly. Both email and webhook notifications are currently supported.

    Here's the documentation on it, deep link into the web hook details: https://octopus.com/docs/administration/subscriptions#Subscriptions...

    Work out how granular you need to filter it, but it sounds like subscribing to the Release document type, and maybe also per project will work for you. I've attached some screen shots.

    Regards,
    Nick

  2. 2 Posted by timbomay on 20 Jul, 2017 03:38 PM

    timbomay's Avatar

    Hi Nick,
    Thanks for getting back to me.
    I did spot this subscriptions feature before, but I disregarded it as it is
    an asynchronous notification mechanism, and I couldn't see a way to inject
    the custom behaviour into the deployment pipeline (process).
    The behaviour I'm hoping to achieve would be to generate a new GUID
    variable per tenant every time I create a release. These variables would
    need to be available for use during the deployment workflow.

    Are there any other approaches to setting (or passing) variables into the
    'create release' operation either by octo.exe, RestAPI or other?

    Cheers
    Tim

  3. Support Staff 3 Posted by Nick Josevski on 21 Jul, 2017 04:10 AM

    Nick Josevski's Avatar

    Hi Tim,

    Because there's no existing feature that does exactly what you want it will be asynchronous, is that of particular concern?

    On the back of a subscription or if you use an automated process to create a release, could you add a variable to the project just before the release is created?

    Example: you're about to make a release 1.0.1-cat, and you add a variable via the API or using octo.exe called Product-Code and you give it a GUID. Repeat for the next release 1.0.1-dog give that same variable a new GUID prior to it's creation.

    This way for each release they snap shot their variables and will have in that same variable name different GUIDs.

    Or am I not understanding your objective?

    As another avenue to investigate, have you considered making use of the Tenants feature, if you use Tenants and Tenant Variables, those are not snapshotted, and you can have and change the variable representing the product code anytime, and at deployment time the release will fetch an "live" value for that variable?

    Multi tenant documentation is here: https://octopus.com/docs/guides/multi-tenant-deployments

    Regards,
    Nick

  4. Paul Stovell closed this discussion on 06 Nov, 2017 11:18 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac