blob: 76b81bfe427fcec174971e36c27de91c3707dabe [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
15def app = ${app}
16def version = ${version}
17def branch = ${branch}
18
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 Hart8d253832017-12-04 08:57:29 -080036 checkout([$class: 'GitSCM',
37 userRemoteConfigs: [[url: 'https://gerrit.opencord.org/' + app]]
38 ])
39
40
Jonathan Hart93be2a02017-12-04 09:23:34 -080041 //stage 'Create support branch'
42 //TODO add a sanity check from human
43 //if (checkBranchExists(app, branch) == 0) {
44 // echo "Branch " + branch + " doesn't exist, creating
45 //createBranch(app, version, 'opencord/master')
46 //} else {
47 // echo "Support branch " + branch + " already exists"
48 //}
Jonathan Hart8d253832017-12-04 08:57:29 -080049
50 stage 'Checkout branch'
51 sh 'cd ' + app + ' && git checkout ' + branch
52
53 stage 'Bump versions'
54 sh 'cd ' + app + ' && mvn change-version'
55
Jonathan Hart93be2a02017-12-04 09:23:34 -080056 //stage 'Commit'
Jonathan Hart8d253832017-12-04 08:57:29 -080057
Jonathan Hart93be2a02017-12-04 09:23:34 -080058 //stage 'Push to Gerrit'
Jonathan Hart8d253832017-12-04 08:57:29 -080059
Jonathan Hart93be2a02017-12-04 09:23:34 -080060 //stage 'Tag'
Jonathan Hart8d253832017-12-04 08:57:29 -080061
Jonathan Hart93be2a02017-12-04 09:23:34 -080062 //stage 'Build and Publish apps'
63 //sh 'cd onos-apps && ./gradlew release'
Jonathan Hart8d253832017-12-04 08:57:29 -080064
Jonathan Hart93be2a02017-12-04 09:23:34 -080065 //stage 'Bump versions forward on branch'
Jonathan Hart8d253832017-12-04 08:57:29 -080066
Jonathan Hart93be2a02017-12-04 09:23:34 -080067 //stage 'Bump versions forward on master'
Jonathan Hart8d253832017-12-04 08:57:29 -080068}