blob: 0aa39bc26d5827ea4db2263557e90c83ebee1dc0 [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}'
Jonathan Hart5cbd2d72017-12-04 13:45:19 -080017def nextVersion = '${nextVersion}'
Jonathan Hart7b395df2017-12-04 10:07:17 -080018def branch = '${branch}'
Jonathan Hart8d253832017-12-04 08:57:29 -080019
Jonathan Hart8d253832017-12-04 08:57:29 -080020
Jonathan Hart2b564992017-12-04 14:07:25 -080021def changeVersion(def newVersion) {
Jonathan Hart5cbd2d72017-12-04 13:45:19 -080022 // TODO any other versions we need to account for?
23 sh 'mvn versions:set -DnewVersion=' + newVersion + ' versions:commit'
24}
25
Jonathan Hart6c0cca02018-05-29 10:43:30 -070026node ('ubuntu16.04-basebuild-1c-2g') {
Jonathan Hart8d253832017-12-04 08:57:29 -080027
Jonathan Hart7942fa02017-12-04 15:43:00 -080028 stage ('Checkout code') {
29 cleanWs()
30
31 git branch: branch, url: 'ssh://jenkins@gerrit.opencord.org:29418/' + app
32
Jonathan Hart5cbd2d72017-12-04 13:45:19 -080033 sh 'gitdir=$(git rev-parse --git-dir); scp -p -P 29418 jenkins@gerrit.opencord.org:hooks/commit-msg ${gitdir}/hooks/'
Jonathan Hart7b395df2017-12-04 10:07:17 -080034 }
Jonathan Hart5cbd2d72017-12-04 13:45:19 -080035
Jonathan Hart7942fa02017-12-04 15:43:00 -080036 stage ('Move to release version') {
Jonathan Hart5cbd2d72017-12-04 13:45:19 -080037 changeVersion(version)
Jonathan Hart5cbd2d72017-12-04 13:45:19 -080038 sh 'git add -A && git commit -m "Release version ' + version + '"'
39 }
Jonathan Hart8d253832017-12-04 08:57:29 -080040
Jonathan Hart7942fa02017-12-04 15:43:00 -080041 // This step is basically to test that everything still builds once the version has
42 // been bumped up before we start pushing things publicly
Jonathan Hart69938f52017-12-04 14:10:59 -080043 stage ('Build and Test') {
Jonathan Hart5cbd2d72017-12-04 13:45:19 -080044 // TODO can we do this with clean .m2?
45 sh 'mvn clean install'
Jonathan Hart7942fa02017-12-04 15:43:00 -080046 sh 'mvn javadoc:javadoc'
Jonathan Hart5cbd2d72017-12-04 13:45:19 -080047 }
48
Jonathan Hart69938f52017-12-04 14:10:59 -080049 stage ('Push to Gerrit') {
Jonathan Hart5cbd2d72017-12-04 13:45:19 -080050 sh 'git push origin HEAD:refs/for/' + branch
51 }
Jonathan Hart8d253832017-12-04 08:57:29 -080052
Jonathan Hart69938f52017-12-04 14:10:59 -080053 stage ('Wait for merge') {
Jonathan Hart5cbd2d72017-12-04 13:45:19 -080054 timeout(time: 1, unit: 'HOURS') {
Jonathan Hart7942fa02017-12-04 15:43:00 -080055 metadata = input id: 'release-build',
56 message: 'Go to Gerrit and merge the release patch',
Jonathan Hart8df16392018-01-12 10:09:37 -080057 submitter: 'jono,dbainbri'
Jonathan Hart5cbd2d72017-12-04 13:45:19 -080058 }
59 }
60
Jonathan Hart69938f52017-12-04 14:10:59 -080061 stage ('Release to Maven Central') {
Jonathan Hart6c0cca02018-05-29 10:43:30 -070062 configFileProvider([configFile(fileId: 'onoscord-apps', variable: 'MAVEN_SETTINGS')]) {
63 sh 'mvn -s $MAVEN_SETTINGS -Prelease clean deploy'
64 }
Jonathan Hart5cbd2d72017-12-04 13:45:19 -080065 }
66
Jonathan Hart7942fa02017-12-04 15:43:00 -080067 stage ('Wait for release on Sonatype') {
Jonathan Hart5cbd2d72017-12-04 13:45:19 -080068 timeout(time: 1, unit: 'HOURS') {
Jonathan Hart7942fa02017-12-04 15:43:00 -080069 metadata = input id: 'release-build',
70 message: 'Go to Sonatype and release the artifacts',
Jonathan Hart8df16392018-01-12 10:09:37 -080071 submitter: 'jono,dbainbri'
Jonathan Hart5cbd2d72017-12-04 13:45:19 -080072 }
73 }
74
Jonathan Hart69938f52017-12-04 14:10:59 -080075 stage ('Tag the release') {
Jonathan Hart5cbd2d72017-12-04 13:45:19 -080076 sh 'git tag -a ' + version + ' -m "Tagging version ' + version + '"'
77 sh 'git push origin ' + version
78 }
79
Jonathan Hart69938f52017-12-04 14:10:59 -080080 stage ('Move to next SNAPSHOT version') {
Jonathan Hart5cbd2d72017-12-04 13:45:19 -080081 def snapshot = nextVersion + '-SNAPSHOT'
82 changeVersion(snapshot)
83 sh 'git add -A && git commit -m "Starting snapshot ' + snapshot + '"'
84 sh 'git push origin HEAD:refs/for/' + branch
85 }
86
Jonathan Hart69938f52017-12-04 14:10:59 -080087 stage ('Finish') {
Jonathan Hart5cbd2d72017-12-04 13:45:19 -080088 sh 'echo "Released new app. Go to Gerrit and merge snapshot version bump"'
89 }
90
Jonathan Hart8d253832017-12-04 08:57:29 -080091}