Jonathan Hart | 93be2a0 | 2017-12-04 09:23:34 -0800 | [diff] [blame] | 1 | // Copyright 2017-present Open Networking Foundation |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
Jonathan Hart | 8d25383 | 2017-12-04 08:57:29 -0800 | [diff] [blame] | 14 | |
Jonathan Hart | 7b395df | 2017-12-04 10:07:17 -0800 | [diff] [blame^] | 15 | def app = '${app}' |
| 16 | def version = '${version}' |
| 17 | def branch = '${branch}' |
Jonathan Hart | 8d25383 | 2017-12-04 08:57:29 -0800 | [diff] [blame] | 18 | |
| 19 | def createBranch(def proj, def branch, def parent) { |
| 20 | cmd = 'ssh -p 29418 gerrit.opencord.org gerrit create-branch ' + proj + " " + branch + " " + parent |
| 21 | sh returnStdout: true, script: cmd |
| 22 | } |
| 23 | |
| 24 | int checkBranchExists(def proj, def branch) { |
| 25 | url = 'https://gerrit.opencord.org/projects/' + proj + '/branches/' + branch |
| 26 | response = httpRequest url: url, validResponseCodes: '200,404' |
| 27 | if (response.status == 404) { |
| 28 | return 1 |
| 29 | } |
| 30 | return 0 |
| 31 | } |
| 32 | |
| 33 | node ('master') { |
| 34 | stage 'Checkout code' |
Jonathan Hart | 93be2a0 | 2017-12-04 09:23:34 -0800 | [diff] [blame] | 35 | //checkout([$class: 'RepoScm', currentBranch: true, manifestRepositoryUrl: 'https://gerrit.opencord.org/manifest', quiet: true]) |
Jonathan Hart | 7b395df | 2017-12-04 10:07:17 -0800 | [diff] [blame^] | 36 | git branch: branch, url: 'https://gerrit.opencord.org/' + app |
Jonathan Hart | 8d25383 | 2017-12-04 08:57:29 -0800 | [diff] [blame] | 37 | |
| 38 | |
Jonathan Hart | 93be2a0 | 2017-12-04 09:23:34 -0800 | [diff] [blame] | 39 | //stage 'Create support branch' |
Jonathan Hart | 93be2a0 | 2017-12-04 09:23:34 -0800 | [diff] [blame] | 40 | //if (checkBranchExists(app, branch) == 0) { |
Jonathan Hart | 7b395df | 2017-12-04 10:07:17 -0800 | [diff] [blame^] | 41 | // echo "Branch " + branch + " doesn't exist, creating |
| 42 | //createBranch(app, version, 'opencord/master') |
| 43 | //} else { |
| 44 | // echo "Support branch " + branch + " already exists" |
| 45 | //} |
| 46 | |
| 47 | stage 'Checkout branch' |
| 48 | sh 'git checkout ' + branch |
| 49 | |
| 50 | stage 'Bump versions' |
| 51 | // TODO any other versions we need to account for? |
| 52 | sh 'mvn versions:set -DnewVersion=' + version + ' versions:commit' |
| 53 | |
| 54 | stage 'Commit' |
| 55 | sh 'git add -A && git commit -m "Release version ' + version + '"' |
| 56 | |
| 57 | stage 'Build and Test' |
| 58 | // TODO can we do this with clean .m2? |
| 59 | sh 'mvn clean install' |
| 60 | |
| 61 | stage 'Push to Gerrit' |
| 62 | sh 'git push opencord HEAD:refs/for/' + branch |
| 63 | |
| 64 | stage 'Wait for merge' |
| 65 | timeout(time: 1, unit: 'HOURS') { |
| 66 | metadata = input id: 'release-build', message: 'Should I perform a release?', |
| 67 | parameters: [booleanParam(defaultValue: true, |
| 68 | description: 'Release onos applications (assumes versions have been updated)', name: 'build_onos_apps'), |
| 69 | string(defaultValue: branch, description: 'Release version', name: 'release_version')], submitter: 'jono' |
| 70 | } |
| 71 | //stage 'Tag' |
Jonathan Hart | 8d25383 | 2017-12-04 08:57:29 -0800 | [diff] [blame] | 72 | |
Jonathan Hart | 93be2a0 | 2017-12-04 09:23:34 -0800 | [diff] [blame] | 73 | //stage 'Build and Publish apps' |
| 74 | //sh 'cd onos-apps && ./gradlew release' |
Jonathan Hart | 8d25383 | 2017-12-04 08:57:29 -0800 | [diff] [blame] | 75 | |
Jonathan Hart | 93be2a0 | 2017-12-04 09:23:34 -0800 | [diff] [blame] | 76 | //stage 'Bump versions forward on branch' |
Jonathan Hart | 8d25383 | 2017-12-04 08:57:29 -0800 | [diff] [blame] | 77 | |
Jonathan Hart | 93be2a0 | 2017-12-04 09:23:34 -0800 | [diff] [blame] | 78 | //stage 'Bump versions forward on master' |
Jonathan Hart | 8d25383 | 2017-12-04 08:57:29 -0800 | [diff] [blame] | 79 | } |