diff --git a/vars/deployPlannerSnapshot.groovy b/vars/deployPlannerSnapshot.groovy index 8cdd8cdd..f898ee78 100644 --- a/vars/deployPlannerSnapshot.groovy +++ b/vars/deployPlannerSnapshot.groovy @@ -10,7 +10,6 @@ def call(body) { body() def yaml - def openShiftProject = config.openShiftProject def openShiftTemplate = config.openShiftTemplate def originalImageName = config.originalImageName def newImageName = config.newImageName @@ -20,8 +19,8 @@ def call(body) { def flow = new io.fabric8.Fabric8Commands() def utils = new io.fabric8.Utils() + def openShiftProject = config.openShiftProject + '-' + utils.getRepoName() - openShiftProject = openShiftProject + '-' + utils.getRepoName() container('clients') { if (!flow.isAuthorCollaborator("", project)){ currentBuild.result = 'ABORTED' @@ -29,13 +28,16 @@ def call(body) { } yaml = flow.getUrlAsString(openShiftTemplate) - yaml = Pattern.compile("- image: ${originalImageName}:(.*)").matcher(yaml).replaceFirst("- image: ${newImageName}") + def originalImage = "- image: ${originalImageName}:(.*)" + def newImage = "- image: ${newImageName}" + yaml = Pattern.compile(originalImage).matcher(yaml).replaceFirst(newImage) - if (!yaml.contains(newImageName)){ - error "original image ${originalImageName} not replaced with ${newImageName} in yaml: \n ${yaml}" + if (!yaml.contains(newImage)){ + error "original image ${originalImageName} not replaced with ${newImage} in yaml: \n ${yaml}" } } - // cant use writeFile as we have long filename errors + // cant use writeFile as we are facing following error + // Scripts not permitted to use staticMethod org.codehaus.groovy.runtime.DefaultGroovyMethods sh "echo '${yaml}' > snapshot.yml" container('clients') {