Octopus Release Version Template - Reset Next Suffix

Stuart Ferguson's Avatar

Stuart Ferguson

24 Apr, 2017 09:37 PM

I am looking at my release versioning in Octopus and have the following as my version template

#{if Octopus.Release.Channel.Name == "Master"}
1.#{Octopus.Version.LastMinor}.#{Octopus.Version.NextPatch}
#{/if}
#{if Octopus.Release.Channel.Name == "Dev"}
1.#{Octopus.Version.LastMinor}.#{Octopus.Version.LastPatch}#{Octopus.Version.Channel.NextSuffix}
#{/if}

The problem I am having is i want my releases to follow this format

Master #1 - 1.0.1
Dev #1 - 1.0.1.1
Dev #2 - 1.0.1.2
Dev #3 - 1.0.1.3
Master #2 - 1.0.2
Dev #4 - 1.0.2.1

What I cant seem to find is a way of resetting the next suffix variable after a master release has been created.

Is this something that is possible with Octopus Deploy?

The version I am using is v3.12.4

Thanks,

Stuart

  1. Support Staff 1 Posted by Daniel Fischer on 27 Apr, 2017 01:11 AM

    Daniel Fischer's Avatar

    Hi Stuart,

    Thanks for getting in touch! I'm sorry for the delay in getting back to you! It turns out, just yesterday, we created a GitHub issue to look into adding this functionality to Octopus.

    Below is the GitHub issue for reference.
    https://github.com/OctopusDeploy/Issues/issues/3442

    So while there is no direct way to do this in Octopus currently, we are looking into adding this functionality. :)

    Let me know if you have any questions or run into any issues.

    Best regards,
    Daniel

  2. 2 Posted by pc1 on 10 May, 2017 10:04 AM

    pc1's Avatar

    Hi Daniel,

    Thanks for this.

    I have one question for you on the change that has been made and that is does the version template support nested if statements.

    For example:

    #{if Octopus.Release.Channel.Name == "Develop"}

      #if(Octopus.Version.Channel[Master].LastMinor == Octopus.Version.Channel[Develop].LastMinor)
        #{Octopus.Version.Channel[Master].LastMajor}.#{Octopus.Version.Channel[Master].LastMinor}#{Octopus.Version.NextSuffix}
      #{/if}

      #if(Octopus.Version.Channel[Master].LastMinor != Octopus.Version.Channel[Develop].LastMinor)
        #{Octopus.Version.Channel[Master].LastMajor}.#{Octopus.Version.Channel[Master].LastMinor}-0
      #{/if}

    #{/if}

  3. Support Staff 3 Posted by Daniel Fischer on 16 May, 2017 05:47 AM

    Daniel Fischer's Avatar

    Hi,

    I'm sorry for the delay in getting back to you. I have run this past the developer who made the changes here. Have you attempted to do this since you posted this? By the looks of it, this should work perfectly fine as it is. If you have tried this and run into any issues, you are more than welcome to let me know what went wrong, and we can try and resolve them.

    Let me know. :)

    Best regards,
    Daniel

  4. 4 Posted by pc1 on 16 May, 2017 07:31 AM

    pc1's Avatar

    Hi Daniel,

    I have tried using this template but when I attempt to create a release the version number is not generated (see attachment).

    Regards,

    Stuart

  5. Support Staff 5 Posted by Daniel Fischer on 17 May, 2017 05:49 AM

    Daniel Fischer's Avatar

    Hi Stuart,

    Thanks for getting back! That's strange, it looks to be working fine on our end. Can you confirm that you have updated to at least Octopus version 3.13.0? As this is the version we released this functionality.

    Looking forward to hearing from you. :)

    Best regards,
    Daniel

  6. 6 Posted by pc1 on 17 May, 2017 07:16 AM

    pc1's Avatar

    Hi Daniel,

    I can confirm the version in use is v3.13.0, the template works fine however when I take out the nested if statements so not sure if they cause the issue or not

    Regards,

    Stuart

  7. Support Staff 7 Posted by Daniel Fischer on 19 May, 2017 01:34 AM

    Daniel Fischer's Avatar

    Hi Stuart,

    Thanks for getting back. One of the developers pointed out that your if statement is not using valid syntax. Sorry for any confusion, I didn't notice initially.

    #{if Octopus.Release.Channel.Name == "Develop"}
    #if(Octopus.Version.Channel[Master].LastMinor == Octopus.Version.Channel[Develop].LastMinor) #{Octopus.Version.Channel[Master].LastMajor}.#{Octopus.Version.Channel[Master].LastMinor}#{Octopus.Version.NextSuffix} #{/if}
    #if(Octopus.Version.Channel[Master].LastMinor != Octopus.Version.Channel[Develop].LastMinor) #{Octopus.Version.Channel[Master].LastMajor}.#{Octopus.Version.Channel[Master].LastMinor}-0 #{/if}
    #{/if}
    

    In your nested if, you are using #if() Octopus is only able to parse curly brackets for our variables and the if must be nested in the brackets like your initial statement. #{if }

    So the working statement should look something like this:

    #{if Octopus.Release.Channel.Name == "Develop"}
    #{if Octopus.Version.Channel[Master].LastMinor == Octopus.Version.Channel[Develop].LastMinor} #{Octopus.Version.Channel[Master].LastMajor}.#{Octopus.Version.Channel[Master].LastMinor}#{Octopus.Version.NextSuffix} #{/if}
    #{if Octopus.Version.Channel[Master].LastMinor != Octopus.Version.Channel[Develop].LastMinor} #{Octopus.Version.Channel[Master].LastMajor}.#{Octopus.Version.Channel[Master].LastMinor}-0 #{/if}
    #{/if}
    

    Have a go with that and let me know if it works. :)

    Best regards,
    Daniel

  8. Paul Stovell closed this discussion on 28 Aug, 2017 06:12 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