annotate scripts/release.groovy @ 216:b628d49d2891

DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
author smith@nwoca.org
date Wed, 29 Jun 2016 13:57:17 +0100
parents 5bebb590b30e
children 49a220a1bde0
rev   line source
208
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
1 #!groovy
216
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
2 import groovy.transform.Sortable
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
3 import groovy.transform.ToString
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
4 import groovy.transform.TupleConstructor
208
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
5
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
6 /**
216
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
7 This script implements the SSDT branching strategy based on hg flow
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
8 and dependency resolution locking.
208
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
9
216
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
10 The intention is to automate of creation of correctly configured release branches.
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
11 The script tries to do the right thing based on standard SSDT project structures,
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
12 but it is the user's responsibility to ensure it's correct.
208
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
13
216
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
14 The script does NOT "hg push --new-branch". That step is left for you
208
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
15 if the branch was created correctly.
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
16
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
17 */
216
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
18
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
19 def branch = new BranchInfo()
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
20
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
21 println "Project:\n"
208
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
22
216
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
23 println "\trepo\t${("hg path".execute().text.split('=') ?: ['', ''])[1].trim()}"
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
24 println "\tbranch\t$branch"
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
25 println "\tversion\t$branch.version"
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
26
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
27 println "-" * 40
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
28 println ""
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
29
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
30 if (args.size() < 1) {
208
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
31 println """
216
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
32 usage: release.groovy {releaseVersion}\n
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
33 e.g: release.groovy 1.6.0
208
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
34
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
35 If release ends in ".0", then will create 'release' stream, otherwise 'hotfix'.
216
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
36 For hotfix, current working branch should be the release branch being hotfix'ed.
208
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
37
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
38 Recommend that this script be executed in a fresh clone of the repo.
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
39
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
40 ** Any uncommitted changes in the working directory will be committed with
215
5bebb590b30e DEP-11: determine project version based on branch
smith@nwoca.org
parents: 208
diff changeset
41 the initial setting of the version. These are assumed to be
208
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
42 'latest.integration' changes.
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
43 """
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
44
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
45 System.exit(0)
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
46 }
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
47
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
48 def releaseVersion = args[0]
216
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
49
208
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
50 def hotfix = !releaseVersion.endsWith('.0')
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
51 def stream = hotfix ? 'hotfix' : 'release'
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
52
216
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
53 println "Creating $stream branch for $releaseVersion"
208
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
54
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
55 checkForSnapshots()
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
56
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
57 println "hg flow $stream start v${releaseVersion} --dry-run".execute().text
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
58
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
59 println "Continue? Enter = Yes, ^C to cancel"
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
60 System.in.newReader().readLine()
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
61
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
62 println "hg flow ${stream} start v${releaseVersion} --dirty".execute().text
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
63
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
64 println "hg update ${stream}/v${releaseVersion}".execute().text
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
65
216
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
66 println "Starting dependency lock via gradle... (please wait)"
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
67 println "cmd /c gradlew.bat deleteGLobalLock generateGlobalLock saveGlobalLock".execute().text
208
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
68
216
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
69 println 'hg commit -A release.lock -m "lock dynamic dependencies for release"'.execute().text
208
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
70
216
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
71 println "Created $releaseVersion $stream branch with locked dynamic dependencies."
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
72 println " Verify the branch and release.lock file created correctly then push the new branch."
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
73 println " If any problems, then delete repo and clone a fresh copy repository."
208
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
74
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
75 def checkForSnapshots() {
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
76 def lines = new File('gradle.properties').readLines() + new File('build.gradle').readLines()
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
77 def snapshots = lines.collect { it.trim() }.findAll{
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
78 it.contains('.SNAPSHOT') && !it.startsWith('version=') ||
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
79 it.contains('latest.') && (it.startsWith('compile') || it.startsWith('runtime'))
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
80 }
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
81 if (snapshots) {
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
82 println "project contains SNAPSHOT dependencies: \n\t" + snapshots.join('\n\t')
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
83 System.exit(1)
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
84 }
216
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
85 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
86
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
87
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
88 @TupleConstructor
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
89 @Sortable
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
90 class Version {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
91
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
92 Integer major = 0
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
93 Integer minor = 0
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
94 Integer patch = 0
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
95 Boolean snapshot = true
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
96
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
97 Version nextVersion() {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
98 new Version(major, minor + 1, 0)
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
99 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
100
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
101 String toString() {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
102 "${major}.${minor}.${patch}${snapshot ? '.SNAPSHOT' : ''}"
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
103 }
208
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
104
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
105 }
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
106
216
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
107
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
108 @ToString(includes=['name','shortName','buildVersion','imageId','deployName'],includeNames= true)
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
109 class BranchInfo {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
110 def name
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
111 def stream = "none"
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
112 def buildNumber = ""
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
113 def changeset = ""
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
114 def version
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
115
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
116 BranchInfo(name = null) {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
117 this.name = name
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
118 if (!name) {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
119 this.name = determineName() ?: ''
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
120 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
121 this.name = this.name.replace('@', '-')
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
122 determineStream()
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
123 buildNumber = System.getenv('bamboo_buildNumber') ?: ""
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
124 changeset = System.getenv('bamboo_planRepository_revision') ?: ""
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
125 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
126
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
127 String getDefaultDependencyStatus() {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
128 return isRelease() ? 'release' : 'integration'
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
129 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
130
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
131 private boolean isRelease() {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
132 return stream in ['release', 'hotfix']
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
133 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
134
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
135 def getShortName() {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
136 def result = name.contains('/') ? name.split('/')[1] : name
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
137 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
138
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
139 String getBuildVersion() {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
140 def v = isRelease() ? shortName - "v": ""
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
141 return v
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
142 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
143
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
144 def Version getVersion() {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
145 if (!version) {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
146 if (isRelease()) {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
147 version = new Version(*getBuildVersion().split('\\.')*.toInteger(), false)
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
148 } else {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
149 version = findSnapshotVersion()
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
150 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
151 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
152 return version
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
153 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
154
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
155 def getImageId() {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
156 (buildVersion ?: shortName.take(25)) + (buildNumber ? "-${buildNumber}" : "-0")
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
157 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
158
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
159 def getDeployName() {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
160 (buildVersion ?: shortName.take(25)).toLowerCase().collectReplacements {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
161 ('a'..'z').contains(it) || ('0'..'9').contains(it) || it == "-" ? null : '-'
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
162 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
163 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
164
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
165 def getHash() {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
166 generateMD5(name)
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
167 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
168 def generateMD5(String s) {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
169 def digest = java.security.MessageDigest.getInstance("MD5")
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
170 digest.update(s.bytes);
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
171 new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0')
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
172 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
173
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
174 private findSnapshotVersion() {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
175 def versions = "hg branches --closed".execute().text.split('\n').findAll {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
176 it.startsWith( 'release') || it.startsWith( 'hotfix')
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
177 }.collect {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
178 it.replaceAll('\\s+',' ').split(' ')[0].split('/')[1] - 'v'
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
179 }.collect {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
180 new Version(*it.split('\\.')*.toInteger())
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
181 }.sort { v1, v2 -> v2 <=> v1 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
182
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
183 return versions ? versions.first().nextVersion() : new Version().nextVersion()
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
184
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
185 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
186
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
187
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
188 def determineName() {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
189 try {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
190 def branch = "hg branch".execute().text.trim()
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
191 def rawParents = 'hg parents'.execute().text
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
192 def parent = rawParents.split('\n').find { it.startsWith("branch") }?.split(":")?.getAt(1)?.trim()
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
193 return parent ?: branch
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
194 } catch (e) {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
195 ['.hg/branch', '../.hg/branch'].findResult {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
196 new File(it).exists() ? new File(it).text : null
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
197 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
198 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
199 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
200
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
201 void determineStream() {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
202 def flowConfig = new File('.hgflow').exists() ? new File('.hgflow') : new File('../.hgflow')
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
203 if (flowConfig.exists()) {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
204 def flows = new Properties()
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
205 flows.load(flowConfig.newReader())
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
206 flows.stringPropertyNames().each {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
207 if (!it.startsWith("[") && name.startsWith(flows.getProperty(it))) {
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
208 stream = it
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
209 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
210 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
211 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
212 }
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
213
b628d49d2891 DEP-11: change name of lock file for release branch. update release script to depend on new resolution and dependency locking
smith@nwoca.org
parents: 215
diff changeset
214 }