// Copyright 2020-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.

/* tost-onos-publish pipeline.*/
pipeline {

  /* executor is determined by JJB */
  agent {
    label "${params.buildNode}"
  }

  /* lighweight version of the docker-publish pipeline. */
  stages {

    stage('checkout') {
      steps {
        checkout([
          $class: 'GitSCM',
          userRemoteConfigs: [[ url: "${params.gitUrl}", credentialsId: 'onos-jenkins-ssh', refspec: "$GERRIT_REFSPEC"]],
          branches: [[ name: "$GERRIT_PATCHSET_REVISION", ]],
          extensions: [
            [$class: 'WipeWorkspace'],
            [$class: 'RelativeTargetDirectory', relativeTargetDir: "$GERRIT_PROJECT"],
            [$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: false],
            [$class: 'SubmoduleOption', recursiveSubmodules: true],
          ],
        ])
        script {
          current_date = sh(returnStdout: true, script: 'date +%Y-%m-%d').trim()
        }
      }
    }

    stage('build'){
      steps {
        script {
          sshagent(credentials: ['github-onf-bot-ssh-key']) {
            withDockerRegistry([credentialsId: 'docker-artifact-push-credentials']) {
              sh( script: """
                #!/usr/bin/env bash
                set -eu -o pipefail

                # checked out in a subdir so the log can be in WORKSPACE
                cd "$GERRIT_PROJECT"

                # set registry/repository variables
                export DOCKER_REGISTRY="$dockerRegistry/"
                export DOCKER_REPOSITORY="$dockerRepo/"

                # Builds having a build date
                if [ ! -z "$buildDate" ]; then
                  export DOCKER_TAG_BUILD_DATE="-$current_date"
                fi

                # Builds having the profiler enabled
                if [ ! -z "$PROFILER" ]; then
                  export DOCKER_TAG_PROFILER="-profiler"
                fi

                # Build w/extraEnvironmentVars
                echo "Building image with following vars $extraEnvironmentVars"
                $extraEnvironmentVars make docker-build 2>&1 | tee "$WORKSPACE/docker-build.log"
              """)
            }
          }
        }
      }
    }

    stage('push'){
      steps {
        script {
          withDockerRegistry(credentialsId: 'aether-internal-registry', url: "https://${params.dockerRegistry}") {
            sh( script:"""
              #!/usr/bin/env bash
              set -eu -o pipefail

              # checked out in a subdir so the log can be in WORKSPACE
              cd "$GERRIT_PROJECT"

              # set registry/repository variables
              export DOCKER_REGISTRY="$dockerRegistry/"
              export DOCKER_REPOSITORY="$dockerRepo/"

              # Builds having a build date
              if [ ! -z "$buildDate" ]; then
                export DOCKER_TAG_BUILD_DATE="-$current_date"
              fi

              # Builds having the profiler enabled
              if [ ! -z "$PROFILER" ]; then
                export DOCKER_TAG_PROFILER="-profiler"
              fi

              # Push w/extraEnvironmentVars
              echo "Pushing image with following vars $extraEnvironmentVars"
              $extraEnvironmentVars make docker-push 2>&1 | tee "$WORKSPACE/docker-push.log"
            """)
          }
        }
      }
    }
  }

  post {
    always {
      archiveArtifacts artifacts: 'docker-*.log', fingerprint: true
      deleteDir()
    }
    failure {
      step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${params.maintainers}", sendToIndividuals: false])
    }
  }
}
