// 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])
    git branch: branch, url: 'https://gerrit.opencord.org/' + app

    
    //stage 'Create support branch'
    //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 'git checkout ' + branch
        
    stage 'Bump versions'
    // TODO any other versions we need to account for?
    sh 'mvn versions:set -DnewVersion=' + version + ' versions:commit'
    
    stage 'Commit'
    sh 'git add -A && git commit -m "Release version ' + version + '"'
    
    stage 'Build and Test'
    // TODO can we do this with clean .m2?
    sh 'mvn clean install'

    stage 'Push to Gerrit'
    sh 'git push opencord HEAD:refs/for/' + branch
    
    stage 'Wait for merge'
    timeout(time: 1, unit: 'HOURS') {
        metadata = input id: 'release-build', message: 'Should I perform a release?',
                parameters: [booleanParam(defaultValue: true,
                description: 'Release onos applications (assumes versions have been updated)', name: 'build_onos_apps'),
                string(defaultValue: branch, description: 'Release version', name: 'release_version')], submitter: 'jono'
    }
    //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'
}
