Jonathan Hart | 8d25383 | 2017-12-04 08:57:29 -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. |
| 14 | |
| 15 | def app = ${app} |
| 16 | def version = ${version} |
| 17 | def branch = ${branch} |
| 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' |
| 35 | #checkout([$class: 'RepoScm', currentBranch: true, manifestRepositoryUrl: 'https://gerrit.opencord.org/manifest', #quiet: true]) |
| 36 | checkout([$class: 'GitSCM', |
| 37 | userRemoteConfigs: [[url: 'https://gerrit.opencord.org/' + app]] |
| 38 | ]) |
| 39 | |
| 40 | |
| 41 | #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 | #} |
| 49 | |
| 50 | stage 'Checkout branch' |
| 51 | sh 'cd ' + app + ' && git checkout ' + branch |
| 52 | |
| 53 | stage 'Bump versions' |
| 54 | sh 'cd ' + app + ' && mvn change-version' |
| 55 | |
| 56 | #stage 'Commit' |
| 57 | |
| 58 | #stage 'Push to Gerrit' |
| 59 | |
| 60 | #stage 'Tag' |
| 61 | |
| 62 | #stage 'Build and Publish apps' |
| 63 | #sh 'cd onos-apps && ./gradlew release' |
| 64 | |
| 65 | #stage 'Bump versions forward on branch' |
| 66 | |
| 67 | #stage 'Bump versions forward on master' |
| 68 | } |