Groovy web console

subscribe to the feed Subscribe
to this
site

image promotion test

Published 4 weeks ago by Anonymous with tags docker images promotion
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
          
def imageName_dev = "dev.2-naap-cpe-management-0.0.3-g839b07"
def imageName_test = "test-naap-cpe-management-0.0.3"
def imageName_rc = "rc-naap-cpe-management-0.0.3"

def validationRegex = /^(ga|rc(\.([0-9]{1,3})){0,1}|dev(\.([0-9]{1,3})){0,1}|test(\.([0-9]{1,3})){0,1}){1}(-([a-z|-]{3,40}[a-z]{0,1})){0,1}-([0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,3})(-([a-z0-9]{7})){0,1}$/           

          // def match = params.image_name =~ imageRegex
            def match1 = imageName_dev =~ validationRegex
            def match2 = imageName_test =~ validationRegex
            def match3 = imageName_rc =~ validationRegex
          if (!match1|!match2|!match3) {
            error("Invalid image name, does not match CaaS specification")
          }
/*
          print match[0][0]
          print match[0][1]
          print match[0][2]
          print match[0][3]
          print match[0][4]
          print match[0][5]
          def imageEnv = match[0][1]
          def buildNr = match[0][2]
          // dev.2-naap-cpe-management-0.0.3-g839b07
          // NEW_TAG = params.env + buildNr + 
          // NEW_TAG = params.image_name + "-" + params.env
        print imageEnv
        print buildNr
*/
// from dev to test, we can just replace the prefix

        def newImageName_test = imageName_dev.replaceFirst("dev", "test")
        print newImageName_test + "\r\n"
        def newImageName_rc = imageName_test.replaceFirst("test", "rc")
        print newImageName_rc + "\r\n"
        def newImageName_ga = imageName_rc.replaceFirst("rc", "ga")
        print newImageName_ga + "\r\n"