simulate post step for dynamically generated Jenkins pipeline stages
You can't use post because post is part of the declarative DSL, not scripted, and you're defining your stages in a script block.  So I'm afraid that as long as you're using a script block to define your stages, you're going to have to stick with the scripted method, which is the groovy try { ... } catch { ... } finally { ... } construct.  For example:

def createStage(String stageName) {
    stage(stageName) {
        try {
            echo "Stage: ${stageName}"
            echo "${stageName} &gt; this is executed only on success"
        finally {
            echo "${stageName} &gt; this is always executed"
        }
    }
}