# Copyright 2017-present Open Networking Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

def app = ${app}
def version = ${version}
def branch = ${branch}

def createBranch(def proj, def branch, def parent) {
    cmd = 'ssh -p 29418 gerrit.opencord.org gerrit create-branch ' + proj + " " + branch + " " + parent
    sh returnStdout: true, script: cmd
}

int checkBranchExists(def proj, def branch) {
    url = 'https://gerrit.opencord.org/projects/' + proj + '/branches/' + branch
    response = httpRequest url: url, validResponseCodes: '200,404'
    if (response.status == 404) {
        return 1
    }
    return 0
}

node ('master') {
    stage 'Checkout code'
    #checkout([$class: 'RepoScm', currentBranch: true, manifestRepositoryUrl: 'https://gerrit.opencord.org/manifest', #quiet: true])
    checkout([$class: 'GitSCM',
        userRemoteConfigs: [[url: 'https://gerrit.opencord.org/' + app]]
    ])

    
    #stage 'Create support branch'
    # TODO add a sanity check from human
    #if (checkBranchExists(app, branch) == 0) {
	#	echo "Branch " + branch + " doesn't exist, creating
		#createBranch(app, version, 'opencord/master')
	#} else {
	#	echo "Support branch " + branch + " already exists"
	#}
	
	stage 'Checkout branch'
	sh 'cd ' + app + ' && git checkout ' + branch
    	
	stage 'Bump versions'
	sh 'cd ' + app + ' && mvn change-version'
	
	#stage 'Commit'
	
	#stage 'Push to Gerrit'
	
	#stage 'Tag'
    
    #stage 'Build and Publish apps'
    #sh 'cd onos-apps && ./gradlew release'
    
    #stage 'Bump versions forward on branch'
    
    #stage 'Bump versions forward on master'
}
