/*
 * pipeline script for Java builds
 * Copyright (c) 2019-2020 StrongBox Data Solutions, Inc.  ALL RIGHTS RESERVED
 *
 */

@Library('buildUtils@develop')_
// run the develop branch 2x daily
String cron_string = BRANCH_NAME == "develop" ? "H 0,6 * * *" : ""

pipeline {
    agent { label "${buildVars.AWS_AGENT}" }
    triggers { cron(cron_string) }
    options {
        ansiColor('xterm')
        timestamps()
    }

    stages {
        stage('Set Properties') {
            steps {
               buildInit()
            }
        }
        stage('Build Jar') {
            steps {
                mvnBuild(kotlin: true, publish: true)
            }
            post {
                always {
                    junit '**/target/surefire-reports/*.xml'
                }
            }
        }
        stage('Package SLU') {
           steps {
              withCredentials([string(credentialsId: 'sign_2021_pp', variable: 'SIGN_PASSPHRASE'),
                               string(credentialsId: 'encr_2021_pp', variable: 'ENCR_PASSPHRASE')]) {
                 createArchive()
              }
           }
        }
        stage('Publish Artifacts and build info') {
            steps {
                endBuild artifacts: 'cicd/Jenkinsfile,build.properties,target/slk-config-tools*.jar'
            }
        }
    }
}
