// 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

                # 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

              # 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])
    }
  }
}
