Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

Pre-Deployment Approval Check that compares the version of my database (a value stored in the database itself) with the $ReleaseNumber and $BuildNumber.



  • My goal is a Pre-Deployment Approval Check that compares the version of my database (a value stored in the database itself) with the $ReleaseNumber and $BuildNumber. The value stored in the database is like 1.2.34567. I will need to do a $ReleaseNumber >= 1.2 AND $BuildNumber > 34567 comparison.

    I have attempted to do this by implementing a variable function in a custom extension but don't have the understanding to get this working or know if this is the best approach.

    Can you please suggest a method to achieve my goal (or an alternative approach) and provide any source code examples that might be applicable.

    Product: BuildMaster
    Version: 4.8.4



  • Hi Jake, great question.

    The best way to accomplish this is to Create a Custom Extension, and then create a class that inherits from PromotionRequirementBase.

    The GetStatus method provides a PromotionContext that has the BuildNumber and ReleaseNumber, and then return the appropriate PromotionRequirementStatus, based on your database query.

    Once this class is implemented and you get the extension in BuildMaster, it will appear on the "add new pre-approval" item list.



  • Hi Alana,

    Is it possible to share the source code of a Promotion Requirement that BuildMaster has implemented itself?

    What is your suggestion to handle different database connection strings? I see the PromotionContext provides CurrentEnvironmentId and TargetEnvironmentId, I could hard code connection strings into the extension based on environments. Is there a way to pass a connection string or read a variable in the GetStatus method?



  • Sure, happy to share the source, though you're welcome to use a disassembler or reflection tool as well -- easiest thing would to fill out the Source Code Request and we'll email it on over.

    If you only ever had a single, well-known database to work with, then hard-coding the connection string isn't too bad of an idea. You can always just update the code and redeploy the extension if it ever changes. But since you have multiple databases... I'm not sure if it's the best approach.

    Otherwise, consider that any property on your class that you mark with the Persistent will be displayed as a textbox and it will be available at runtime. So, two ideas come to mind:

    1. You could have a ConnectionSTring property, and just use that; that would be quite easy
    2. You could have DatabaseConnectionName property, and have that reference a database connection within your application; these are used to deploy database changes

    The DatabaseConnectionName will be a little trickier, as you'll have to retrieve it from the database, then deserialize it, then look at the object's connection string property. All of the Database ACtions do this, so you can look at their source code.

    You'd only want to do this if you're already using database connections.


Log in to reply
 

Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation