blob: 0bb6bb845ae89ff740757b4ac8c81bb37206cfa4 [file] [log] [blame]
Jonathan Hart93be2a02017-12-04 09:23:34 -08001// 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 Hart8d253832017-12-04 08:57:29 -080014
Jonathan Hart7b395df2017-12-04 10:07:17 -080015def app = '${app}'
16def version = '${version}'
17def branch = '${branch}'
Jonathan Hart8d253832017-12-04 08:57:29 -080018
19def 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
24int 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
33node ('master') {
34 stage 'Checkout code'
Jonathan Hart93be2a02017-12-04 09:23:34 -080035 //checkout([$class: 'RepoScm', currentBranch: true, manifestRepositoryUrl: 'https://gerrit.opencord.org/manifest', quiet: true])
Jonathan Hart7b395df2017-12-04 10:07:17 -080036 git branch: branch, url: 'https://gerrit.opencord.org/' + app
Jonathan Hart8d253832017-12-04 08:57:29 -080037
38
Jonathan Hart93be2a02017-12-04 09:23:34 -080039 //stage 'Create support branch'
Jonathan Hart93be2a02017-12-04 09:23:34 -080040 //if (checkBranchExists(app, branch) == 0) {
Jonathan Hart7b395df2017-12-04 10:07:17 -080041 // 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 Hart8d253832017-12-04 08:57:29 -080072
Jonathan Hart93be2a02017-12-04 09:23:34 -080073 //stage 'Build and Publish apps'
74 //sh 'cd onos-apps && ./gradlew release'
Jonathan Hart8d253832017-12-04 08:57:29 -080075
Jonathan Hart93be2a02017-12-04 09:23:34 -080076 //stage 'Bump versions forward on branch'
Jonathan Hart8d253832017-12-04 08:57:29 -080077
Jonathan Hart93be2a02017-12-04 09:23:34 -080078 //stage 'Bump versions forward on master'
Jonathan Hart8d253832017-12-04 08:57:29 -080079}