comparison init20.gradle @ 209:07baf02b6034

add helper for calculating imageid
author smith@nwoca.org
date Sat, 19 Dec 2015 15:30:52 +0000
parents cf65e7327fe8
children 068d09f5b627
comparison
equal deleted inserted replaced
208:f200b931ea9d 209:07baf02b6034
62 gradle.ext.branchName = gradle.branch.name 62 gradle.ext.branchName = gradle.branch.name
63 gradle.ext.branchStream = gradle.branch.stream 63 gradle.ext.branchStream = gradle.branch.stream
64 gradle.ext.branchHash = gradle.branch.hash 64 gradle.ext.branchHash = gradle.branch.hash
65 println "${gradle.hgRepositoryUrl} ${gradle.branch}" 65 println "${gradle.hgRepositoryUrl} ${gradle.branch}"
66 println "$gradle.runtimeInfo" 66 println "$gradle.runtimeInfo"
67 println gradle.branch
68 println gradle.branch.imageId
67 69
68 loadEnvironments() 70 loadEnvironments()
69 71
70 gradle.environment.put('hgRepositoryUrl', gradle.hgRepositoryUrl) 72 gradle.environment.put('hgRepositoryUrl', gradle.hgRepositoryUrl)
71 gradle.environment.put('branchName', gradle.branch.name) 73 gradle.environment.put('branchName', gradle.branch.name)
569 571
570 } 572 }
571 573
572 574
573 575
574 @ToString 576 @ToString(includes=['name','shortName','buildVersion','imageId'],includeNames= true)
575 class BranchInfo { 577 class BranchInfo {
576 def name 578 def name
577 def stream = "none" 579 def stream = "none"
580 def buildNumber = ""
578 581
579 BranchInfo(name) { 582 BranchInfo(name) {
580 this.name = name 583 this.name = name
581 if (!name) { 584 if (!name) {
582 this.name = determineName() ?: '' 585 this.name = determineName() ?: ''
583 } 586 }
584 this.name = this.name.replace('@', '-') 587 this.name = this.name.replace('@', '-')
585 determineStream() 588 determineStream()
586 } 589 buildNumber = System.getenv('bamboo_buildNumber') ?: ""
590 }
591
592 def getShortName() {
593 def result = name.contains('/') ? name.split('/')[1] : name
594 }
595
596 def getBuildVersion() {
597 stream in ['release','hotfix'] ? shortName - "v": ""
598 }
599
600 def getImageId() {
601 (buildVersion ?: shortName.take(20)) + (buildNumber ? "-${buildNumber}" : "")
602 }
587 603
588 def getHash() { 604 def getHash() {
589 generateMD5(name) 605 generateMD5(name)
590 } 606 }
591 def generateMD5(String s) { 607 def generateMD5(String s) {